[FIX] account_anglo_saxon: incorrect account tax

When changing the account_id of an invoice line, all the tax line,
created from this invoice line and with a tax which has no
"account_collected_id" set, must be set with the same account_id.
Inspired from the function "compute" in model "account.invoice.tax"

closed #9727
This commit is contained in:
Goffin Simon 2015-12-04 10:50:58 +01:00
parent 0de99dd2c8
commit 85e33c8e1d
1 changed files with 5 additions and 0 deletions

View File

@ -54,6 +54,11 @@ class stock_picking(osv.osv):
if oa:
fpos = ol.invoice_id.fiscal_position or False
a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa)
tax_line = ol.invoice_line_tax_id.filtered(lambda l: not l.account_collected_id) if ol.invoice_line_tax_id else False
if tax_line:
for tax in tax_line:
tax_id = self.pool['account.invoice.tax'].search(cr, uid, [('invoice_id', '=', ol.invoice_id.id), ('name', '=', tax.name), ('account_id', '=', ol.account_id.id)], limit=1)
self.pool['account.invoice.tax'].write(cr, uid, tax_id, {'account_id': a})
self.pool.get('account.invoice.line').write(cr, uid, [ol.id], {'account_id': a})
return res