From 18b7b28bc1ee676a8d245f50821d4a9aeb844158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Mon, 23 Jun 2014 17:23:32 +0200 Subject: [PATCH] [FIX] account: backport of 12a39db [FIX] account: Preserve analytic account on tax lines which are on same general account as invoice line After careful analysis, I'm now convinced it is a good thing to preserve the analytic account on taxes line which have the same general account as the invoice line. This is the best default case and will save time for users, while leaving the flexibility to adapt the analytic account on taxes manually. --- addons/account/account_invoice.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index dee2e1dab6e..febddd3c7f2 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1743,6 +1743,14 @@ class account_invoice_tax(osv.osv): val['account_id'] = tax['account_paid_id'] or line.account_id.id val['account_analytic_id'] = tax['account_analytic_paid_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