From 8ad0c0f3abe77221e9ade5b60f59e8026405acd6 Mon Sep 17 00:00:00 2001 From: Goffin Simon <sig@odoo.com> Date: Tue, 10 May 2016 11:11:07 +0200 Subject: [PATCH] [FIX] account: base field in account.invoice.tax The field base is obligatory according to a european law. This field existed in saas-6. opw:674713 --- addons/account/models/account_invoice.py | 11 +++++++++++ addons/account/views/account_invoice_view.xml | 2 ++ addons/account/views/report_invoice.xml | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 5f415d71b4bd..89a6dcd1cb09 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1233,6 +1233,14 @@ class AccountInvoiceTax(models.Model): _description = "Invoice Tax" _order = 'sequence' + def _compute_base_amount(self): + for tax in self: + base = 0.0 + for line in tax.invoice_id.invoice_line_ids: + if tax.tax_id in line.invoice_line_tax_ids: + base += line.price_subtotal + tax.base = base + invoice_id = fields.Many2one('account.invoice', string='Invoice', ondelete='cascade', index=True) name = fields.Char(string='Tax Description', required=True) tax_id = fields.Many2one('account.tax', string='Tax') @@ -1243,6 +1251,9 @@ class AccountInvoiceTax(models.Model): sequence = fields.Integer(help="Gives the sequence order when displaying a list of invoice tax.") company_id = fields.Many2one('res.company', string='Company', related='account_id.company_id', store=True, readonly=True) currency_id = fields.Many2one('res.currency', related='invoice_id.currency_id', store=True, readonly=True) + base = fields.Monetary(string='Base', compute='_compute_base_amount') + + class AccountPaymentTerm(models.Model): diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml index 197211592242..732fa72388b9 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -93,6 +93,7 @@ <field name="manual"/> <field name="name"/> <field name="account_id" groups="base.group_account_user"/> + <field name="base"/> <field name="amount"/> <field name="currency_id" invisible="1"/> </tree> @@ -111,6 +112,7 @@ <field name="account_analytic_id" domain="[('company_id', '=', parent.company_id), ('account_type', '=', 'normal')]" groups="analytic.group_analytic_accounting"/> <field name="manual"/> <field name="amount"/> + <field name="base"/> <field name="currency_id" invisible="1"/> </group> </form> diff --git a/addons/account/views/report_invoice.xml b/addons/account/views/report_invoice.xml index 1bccecfca4a2..b16413aae0dd 100644 --- a/addons/account/views/report_invoice.xml +++ b/addons/account/views/report_invoice.xml @@ -122,12 +122,17 @@ <thead> <tr> <th>Tax</th> + <th class="text-right">Base</th> <th class="text-right">Amount</th> </tr> </thead> <tbody> <tr t-foreach="o.tax_line_ids" t-as="t"> <td><span t-field="t.name"/></td> + <td class="text-right"> + <span t-field="t.base" + t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/> + </td> <td class="text-right"> <span t-field="t.amount" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/> -- GitLab