From df2ef36c09f60b581112e738dd39a5e592b16df6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 13 Apr 2012 13:21:07 +0200 Subject: [PATCH] Use default values when adding a record via on_change review324001 --- move.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/move.py b/move.py index 1518fae269..dc38641e4b 100644 --- a/move.py +++ b/move.py @@ -792,6 +792,8 @@ class Line(ModelSQL, ModelView): account_obj = pool.get('account.account') tax_code_obj = pool.get('account.tax.code') tax_obj = pool.get('account.tax') + tax_line_obj = pool.get('account.tax.line') + if vals.get('move'): #Only for first line return res @@ -826,14 +828,18 @@ class Line(ModelSQL, ModelView): 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, tax_id], - 'currency_digits': account.currency_digits, - 'code': code_id, - 'code.rec_name': tax_code_obj.browse(code_id).rec_name, - 'tax': tax_id, - 'tax.rec_name': tax_obj.browse(tax_id).rec_name, - }) + value = tax_line_obj.default_get( + tax_line_obj._columns.keys()) + value.update({ + 'amount': base_amounts[code_id, tax_id], + 'currency_digits': account.currency_digits, + 'code': code_id, + 'code.rec_name': tax_code_obj.browse( + code_id).rec_name, + 'tax': tax_id, + 'tax.rec_name': tax_obj.browse(tax_id).rec_name, + }) + res.setdefault('add', []).append(value) return res def on_change_party(self, vals):