diff --git a/CHANGELOG b/CHANGELOG
index 747df4034d..af0f516dc6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,4 @@
+* Add tax field on account.tax.line
* Remove unique constraint on tax group code column
* Add default search value on account move
* Remove egenix-mx-base and replace it by python-dateutil
diff --git a/move.py b/move.py
index cf1b7dab0a..bf01455d37 100644
--- a/move.py
+++ b/move.py
@@ -634,16 +634,17 @@ class Line(ModelSQL, ModelView):
code_id = tax.credit_note_tax_code.id
account_id = tax.credit_note_account.id
if base_id in line_code_taxes or not base_id:
- taxes.setdefault((account_id, code_id), False)
+ taxes.setdefault((account_id, code_id, tax.id), False)
for tax_line in line.tax_lines:
- taxes[(line.account.id, tax_line.code.id)] = True
+ 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)] = True
+ 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)] = True
+ taxes[(line.account.id, False, False)] = True
if 'account' in fields:
if total >= Decimal('0.0'):
@@ -658,8 +659,8 @@ class Line(ModelSQL, ModelView):
values.setdefault('credit', total > 0 and total or False)
if move.journal.type in ('expense', 'revenue'):
- for account_id, code_id in taxes:
- if taxes[(account_id, code_id)]:
+ for account_id, code_id, tax_id in taxes:
+ if taxes[(account_id, code_id, tax_id)]:
continue
for line in move.lines:
if move.journal.type == 'revenue':
@@ -679,8 +680,9 @@ class Line(ModelSQL, ModelView):
line.debit or line.credit, 1, context=context):
if (tax_line['tax'][key + '_account'].id \
or line.account.id) == account_id \
- and tax_line['tax'][key + '_tax_code'].id \
- == code_id:
+ and tax_line['tax'][key + '_tax_code'].id \
+ == code_id \
+ and tax_line['tax'].id == tax_id:
if line.debit:
line_amount += tax_line['amount']
else:
@@ -709,6 +711,9 @@ class Line(ModelSQL, ModelView):
'code': code_id,
'code.rec_name': tax_code_obj.browse(cursor,
user, code_id, context=context).rec_name,
+ 'tax': tax_id,
+ 'tax.rec_name': tax_obj.browse(cursor, user,
+ tax_id, context=context).rec_name
},
]
return values
@@ -820,18 +825,22 @@ 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
- base_amounts.setdefault(code_id, Decimal('0.0'))
- base_amounts[code_id] += tax_line['base'] * \
+ 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'] * \
tax_line['tax'][key + '_tax_sign']
- for code_id in base_amounts:
- if not code_id:
+ for code_id, tax_id in base_amounts:
+ if not base_amounts[code_id, tax_id]:
continue
res.setdefault('add', []).append({
- 'amount': base_amounts[code_id],
+ 'amount': base_amounts[code_id, tax_id],
'currency_digits': account.currency_digits,
'code': code_id,
'code.rec_name': tax_code_obj.browse(cursor, user,
- code_id, context=context).rec_name,
+ code_id, context=context).rec_name,
+ 'tax': tax_id,
+ 'tax.rec_name': tax_obj.browse(cursor, user,
+ tax_id, context=context).rec_name
})
return res
diff --git a/tax.py b/tax.py
index 8e3b77a9fa..bbaeef7076 100644
--- a/tax.py
+++ b/tax.py
@@ -941,6 +941,8 @@ class Line(ModelSQL, ModelView):
amount = fields.Numeric('Amount', digits=(16, Eval('currency_digits', 2)),
depends=['currency_digits'])
code = fields.Many2One('account.tax.code', 'Code', select=1, required=True)
+ tax = fields.Many2One('account.tax', 'Tax', select=1, ondelete='RESTRICT',
+ on_change=['tax'])
move_line = fields.Many2One('account.move.line', 'Move Line',
required=True, select=1, ondelete='CASCADE')
@@ -959,6 +961,12 @@ class Line(ModelSQL, ModelView):
res[line.id] = line.move_line.currency_digits
return res
+ def on_change_tax(self, cursor, user, ids, vals, context=None):
+ res = {
+ 'code': False,
+ }
+ return res
+
Line()
diff --git a/tax.xml b/tax.xml
index d5100cbed3..91d6fa506d 100644
--- a/tax.xml
+++ b/tax.xml
@@ -563,10 +563,12 @@ this repository contains the full copyright notices and license terms. -->
-
-
+
+
+
+
]]>
@@ -577,8 +579,9 @@ this repository contains the full copyright notices and license terms. -->
-
+
+
]]>