Browse Source

[IMP] Improved code

pull/264/head
Nikul-Chaudhary 6 years ago
parent
commit
08409eb3ef
  1. 2
      contract_section/models/account_analytic_account.py
  2. 8
      contract_section/models/account_analytic_contract_line.py
  3. 12
      contract_section/tests/test_contract.py
  4. 2
      contract_section/views/account_analytic_account.xml
  5. 2
      contract_section/views/account_analytic_contract.xml

2
contract_section/models/account_analytic_account.py

@ -12,6 +12,6 @@ class AccountAnalyticAccount(models.Model):
invoice_line_vals = super(AccountAnalyticAccount, self). \
_prepare_invoice_line(line, invoice_id)
invoice_line_vals.update({
'layout_category_id': line.layout_category_id.id,
'display_type': line.display_type,
})
return invoice_line_vals

8
contract_section/models/account_analytic_contract_line.py

@ -7,7 +7,9 @@ from odoo import fields, models
class AccountAnalyticContractLine(models.Model):
_inherit = 'account.analytic.contract.line'
layout_category_id = fields.Many2one(
'sale.layout_category',
string='Section'
display_type = fields.Selection([
('line_section', "Section"),
('line_note', "Note")],
default=False,
help="Technical field for UX purpose."
)

12
contract_section/tests/test_contract.py

@ -13,14 +13,8 @@ class TestContract(TestContractBase):
# contract line
super(TestContract, cls).setUpClass()
cls.acct_line.unlink()
cls.section = cls.env['sale.layout_category'].create({
'name': 'Services',
'subtotal': True,
'pagebreak': True,
'sequence': 1
})
cls.line_vals.update({
'layout_category_id': cls.section.id,
'display_type': 'line_section',
})
cls.acct_line = cls.env['account.analytic.invoice.line'].create(
cls.line_vals,
@ -32,5 +26,5 @@ class TestContract(TestContractBase):
self.contract.recurring_create_invoice()
invoice_id = self.env['account.invoice'].search(
[('contract_id', '=', self.contract.id)])
self.assertEqual(invoice_id.invoice_line_ids.layout_category_id.id,
self.line_vals['layout_category_id'])
self.assertEqual(invoice_id.invoice_line_ids.display_type,
self.line_vals['display_type'])

2
contract_section/views/account_analytic_account.xml

@ -7,7 +7,7 @@
<field name="arch" type="xml">
<xpath expr='//field[@name="recurring_invoice_line_ids"]/tree//field[@name="name"]'
position="after">
<field name="layout_category_id" groups="sale.group_sale_layout"/>
<field name="display_type"/>
</xpath>
</field>
</record>

2
contract_section/views/account_analytic_contract.xml

@ -7,7 +7,7 @@
<field name="arch" type="xml">
<xpath expr='//field[@name="recurring_invoice_line_ids"]/tree//field[@name="name"]'
position="after">
<field name="layout_category_id" groups="sale.group_sale_layout"/>
<field name="display_type"/>
</xpath>
</field>
</record>

Loading…
Cancel
Save