Merge lp:~acsone-openerp/openobject-addons/7.0-bug-1084822-analytic-taxes into lp:openobject-addons/7.0

Proposed by Stéphane Bidoul (Acsone)
Status: Needs review
Proposed branch: lp:~acsone-openerp/openobject-addons/7.0-bug-1084822-analytic-taxes
Merge into: lp:openobject-addons/7.0
Diff against target: 27 lines (+9/-1)
1 file modified
account/account_invoice.py (+9/-1)
To merge this branch: bzr merge lp:~acsone-openerp/openobject-addons/7.0-bug-1084822-analytic-taxes
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+166257@code.launchpad.net

Description of the change

To post a comment you must log in.
9181. By Stéphane Bidoul (Acsone)

Merge 7.0 in the hope it will become green on runbot

Unmerged revisions

9181. By Stéphane Bidoul (Acsone)

Merge 7.0 in the hope it will become green on runbot

9180. By Laetitia Gangloff (Acsone)

account_invoice: set analytic account on taxes if there is no default and it is the samefinancial account than the invoice line.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account_invoice.py'
2--- account/account_invoice.py 2013-09-20 09:50:26 +0000
3+++ account/account_invoice.py 2014-01-20 10:20:17 +0000
4@@ -1655,7 +1655,7 @@
5 'invoice_id': fields.many2one('account.invoice', 'Invoice Line', ondelete='cascade', select=True),
6 'name': fields.char('Tax Description', size=64, required=True),
7 'account_id': fields.many2one('account.account', 'Tax Account', required=True, domain=[('type','<>','view'),('type','<>','income'), ('type', '<>', 'closed')]),
8- 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account'),
9+ 'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic account', readonly=True),
10 'base': fields.float('Base', digits_compute=dp.get_precision('Account')),
11 'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
12 'manual': fields.boolean('Manual'),
13@@ -1733,6 +1733,14 @@
14 val['account_id'] = tax['account_paid_id'] or line.account_id.id
15 val['account_analytic_id'] = tax['account_analytic_paid_id']
16
17+ # If the taxes generate moves on the same financial account as the invoice line
18+ # and no default analytic account is defined at the tax level, propagate the
19+ # analytic account from the invoice line to the tax line. This is necessary
20+ # in situations were (part of) the taxes cannot be reclaimed,
21+ # to ensure the tax move is allocated to the proper analytic account.
22+ if not val.get('account_analytic_id') and line.account_analytic_id and val['account_id'] == line.account_id.id:
23+ val['account_analytic_id'] = line.account_analytic_id.id
24+
25 key = (val['tax_code_id'], val['base_code_id'], val['account_id'], val['account_analytic_id'])
26 if not key in tax_grouped:
27 tax_grouped[key] = val