Skip to content

Commit

Permalink
[FIX] account_invoice: set analytic account on taxes if there is no d…
Browse files Browse the repository at this point in the history
…efault

and it is the same financial account than the invoice line.

https://launchpad.net/bugs/1084822
  • Loading branch information
sbidoul authored and Stefan Rijnhart committed Jul 2, 2014
1 parent 6267eb6 commit 7b7ca96
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion addons/account/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ def _count_factor(self, cr, uid, ids, name, args, context=None):
'invoice_id': fields.many2one('account.invoice', 'Invoice Line', ondelete='cascade', select=True),
'name': fields.char('Tax Description', size=64, required=True),
'account_id': fields.many2one('account.account', 'Tax Account', required=True, domain=[('type','<>','view'),('type','<>','income'), ('type', '<>', 'closed')]),
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'),
'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account', readonly=True),
'base': fields.float('Base', digits_compute=dp.get_precision('Account')),
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
'manual': fields.boolean('Manual'),
Expand Down Expand Up @@ -1753,6 +1753,14 @@ def compute(self, cr, uid, invoice_id, context=None):
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'], val['account_analytic_id'])
if not key in tax_grouped:
tax_grouped[key] = val
Expand Down

0 comments on commit 7b7ca96

Please sign in to comment.