summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorRaphael Collet <rco@openerp.com>2016-10-21 09:34:39 +0200
committerNicolas Martinelli <nim@odoo.com>2016-10-21 09:46:59 +0200
commitbde400ca3e70d5fd5e3b30fc5ee780da7fb89cfe (patch)
tree7ac19ac6736a2b4cd4b63bb7b192dce3257930f4 /addons
parentd31bd1feb0a05035b648c1ead76ab925ce2fb284 (diff)
[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.
Diffstat (limited to 'addons')
-rw-r--r--addons/account/models/account_invoice.py19
1 files 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)