From 0b9ac89aff685b01d859cbf2ca1cb86914fd3ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 31 Dec 2010 12:37:06 +0100 Subject: [PATCH] Fix default taxes computation when tax doesn't have code for issue1788 (transplanted from 64a97ccad41557ec236588cf741ad59f091a8cc9) --- move.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/move.py b/move.py index 758312e15a..c7e28298bc 100644 --- a/move.py +++ b/move.py @@ -636,13 +636,15 @@ class Line(ModelSQL, ModelView): for tax_line in line.tax_lines: taxes[(line.account.id, tax_line.code.id, tax_line.tax.id)] = True - if not line.tax_lines and line.account.taxes: - if line.account.id in no_code_taxes: - taxes[(line.account.id, False, False)] = True - else: - no_code_taxes.append(line.account.id) - elif not line.tax_lines: - taxes[(line.account.id, False, False)] = True + if not line.tax_lines: + no_code_taxes.append(line.account.id) + for no_code_account_id in no_code_taxes: + for (account_id, code_id, tax_id), test in \ + taxes.iteritems(): + if (not test + and not code_id + and no_code_account_id == account_id): + taxes[(account_id, code_id, tax_id)] = True if 'account' in fields: if total >= Decimal('0.0'): @@ -823,6 +825,8 @@ class Line(ModelSQL, ModelView): [x.id for x in account.taxes], debit or credit, 1, context=context): code_id = tax_line['tax'][key + '_base_code'].id + if not code_id: + continue tax_id = tax_line['tax'].id base_amounts.setdefault((code_id, tax_id), Decimal('0.0')) base_amounts[code_id, tax_id] += tax_line['base'] * \