diff options
| author | qdp-odoo <qdp@openerp.com> | 2014-07-14 11:48:26 +0200 |
|---|---|---|
| committer | qdp-odoo <qdp@openerp.com> | 2014-07-14 11:48:26 +0200 |
| commit | bcfa4c8e7ca4f8fb3b577e32eca9f3c0e8f99190 (patch) | |
| tree | 1304b7e2ca3b0f6a383e164208b170b29a5d972a /addons | |
| parent | 9fe9b6305b370fdb9eda778bbb0d5d63c828a08b (diff) | |
| parent | 12a39db8c3ac5741f7b52d40c94b81f1e51c6dd0 (diff) | |
Merge pull request #402 from acsone/bug-lp1084822-sbi
[FIX] Global taxes warning on tax analytic account
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/account/account_invoice.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 455feb14afb..f9e9ff2813d 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -145,7 +145,7 @@ class account_invoice(models.Model): else: self.residual = new_value # prevent the residual amount on the invoice to be less than 0 - self.residual = max(self.residual, 0.0) + self.residual = max(self.residual, 0.0) @api.one @api.depends( @@ -712,7 +712,7 @@ class account_invoice(models.Model): for tax in self.tax_line: if tax.manual: continue - key = (tax.tax_code_id.id, tax.base_code_id.id, tax.account_id.id, tax.account_analytic_id.id) + key = (tax.tax_code_id.id, tax.base_code_id.id, tax.account_id.id) tax_key.append(key) if key not in compute_taxes: raise except_orm(_('Warning!'), _('Global taxes defined, but they are not in invoice lines !')) @@ -1549,7 +1549,15 @@ class account_invoice_tax(models.Model): val['account_id'] = tax['account_paid_id'] or line.account_id.id val['account_analytic_id'] = tax['account_analytic_paid_id'] - key = (val['tax_code_id'], val['base_code_id'], val['account_id'], val['account_analytic_id']) + # If the taxes generate moves on the same financial account as the invoice line + # and no default analytic account is defined at the tax level, propagate the + # analytic account from the invoice line to the tax line. This is necessary + # in situations were (part of) the taxes cannot be reclaimed, + # to ensure the tax move is allocated to the proper analytic account. + if not val.get('account_analytic_id') and line.account_analytic_id and val['account_id'] == line.account_id.id: + val['account_analytic_id'] = line.account_analytic_id.id + + key = (val['tax_code_id'], val['base_code_id'], val['account_id']) if not key in tax_grouped: tax_grouped[key] = val else: |
