From bde400ca3e70d5fd5e3b30fc5ee780da7fb89cfe Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 21 Oct 2016 09:34:39 +0200 Subject: [PATCH] [FIX] account: account tax base computation In the earlier fix 327f88df, the computation of the amount crashes when the field `tax_id` is not set. Simply add an 'if' statement to avoid that case. --- addons/account/models/account_invoice.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 41058dfa200..1f86bfb5158 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1302,15 +1302,16 @@ class AccountInvoiceTax(models.Model): for invoice in self.mapped('invoice_id'): tax_grouped[invoice.id] = invoice.get_taxes_values() for tax in self: - key = self.env['account.tax'].browse(tax.tax_id.id).get_grouping_key({ - 'tax_id': tax.tax_id.id, - 'account_id': tax.account_id.id, - 'account_analytic_id': tax.account_analytic_id.id, - }) - if tax.invoice_id and key in tax_grouped[tax.invoice_id.id]: - tax.base = tax_grouped[tax.invoice_id.id][key]['base'] - else: - _logger.warning('Tax Base Amount not computable probably due to a change in an underlying tax (%s).', tax.tax_id.name) + if tax.tax_id: + key = tax.tax_id.get_grouping_key({ + 'tax_id': tax.tax_id.id, + 'account_id': tax.account_id.id, + 'account_analytic_id': tax.account_analytic_id.id, + }) + if tax.invoice_id and key in tax_grouped[tax.invoice_id.id]: + tax.base = tax_grouped[tax.invoice_id.id][key]['base'] + else: + _logger.warning('Tax Base Amount not computable probably due to a change in an underlying tax (%s).', tax.tax_id.name) invoice_id = fields.Many2one('account.invoice', string='Invoice', ondelete='cascade', index=True) name = fields.Char(string='Tax Description', required=True)