From 39010d38567a4d679cbdb8c0e21cffec6c3bb6b0 Mon Sep 17 00:00:00 2001 From: Somesh Khare Date: Fri, 21 Nov 2014 10:46:35 +0530 Subject: [PATCH] [FIX] account: wrong amount for tax included Backport of 8.0 code, rev f61339b Create a new journal item with an tax included, the automatically created tax line had the amount computed as tax excluded. Fixes #3731, opw 618305 --- addons/account/account_move_line.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index e79fde1df8f..9287ed239c4 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -1246,15 +1246,23 @@ class account_move_line(osv.osv): base_sign = 'base_sign' tax_sign = 'tax_sign' tmp_cnt = 0 - for tax in tax_obj.compute_all(cr, uid, [tax_id], total, 1.00, force_excluded=True).get('taxes'): + for tax in tax_obj.compute_all(cr, uid, [tax_id], total, 1.00, force_excluded=False).get('taxes'): #create the base movement if tmp_cnt == 0: if tax[base_code]: tmp_cnt += 1 - self.write(cr, uid,[result], { + if tax_id.price_include: + total = tax['price_unit'] + newvals = { 'tax_code_id': tax[base_code], - 'tax_amount': tax[base_sign] * abs(total) - }) + 'tax_amount': tax[base_sign] * abs(total), + } + if tax_id.price_include: + if tax['price_unit'] < 0: + newvals['credit'] = abs(tax['price_unit']) + else: + newvals['debit'] = tax['price_unit'] + self.write(cr, uid, [result], newvals, context=context) else: data = { 'move_id': vals['move_id'],