Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 12a39db

Browse files
committed
[FIX] 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.
1 parent 3470643 commit 12a39db

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

addons/account/account_invoice.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def _compute_residual(self):
145145
else:
146146
self.residual = new_value
147147
# prevent the residual amount on the invoice to be less than 0
148-
self.residual = max(self.residual, 0.0)
148+
self.residual = max(self.residual, 0.0)
149149

150150
@api.one
151151
@api.depends(
@@ -1549,6 +1549,14 @@ def compute(self, invoice):
15491549
val['account_id'] = tax['account_paid_id'] or line.account_id.id
15501550
val['account_analytic_id'] = tax['account_analytic_paid_id']
15511551

1552+
# If the taxes generate moves on the same financial account as the invoice line
1553+
# and no default analytic account is defined at the tax level, propagate the
1554+
# analytic account from the invoice line to the tax line. This is necessary
1555+
# in situations were (part of) the taxes cannot be reclaimed,
1556+
# to ensure the tax move is allocated to the proper analytic account.
1557+
if not val.get('account_analytic_id') and line.account_analytic_id and val['account_id'] == line.account_id.id:
1558+
val['account_analytic_id'] = line.account_analytic_id.id
1559+
15521560
key = (val['tax_code_id'], val['base_code_id'], val['account_id'])
15531561
if not key in tax_grouped:
15541562
tax_grouped[key] = val

0 commit comments

Comments
 (0)