Use account taxes as default value for taxes if no product is set

review39001
This commit is contained in:
Cédric Krier committed 2011-06-07 11:55:40 +02:00
1 parent ecf0e63203
commit 42fee1ba5c
1 file changed
+14 -1
+14 -1
View File
@@ -1279,7 +1279,7 @@ class InvoiceLine(ModelSQL, ModelView):
('company', '=', Get(Eval('_parent_invoice', {}), 'company',
Eval('company'))),
('id', '!=', Get(Eval('_parent_invoice', {}), 'account', 0)),
],
], on_change=['account', 'product'],
states={
'invisible': Not(Equal(Eval('type'), 'line')),
'required': Equal(Eval('type'), 'line'),
@@ -1620,6 +1620,19 @@ class InvoiceLine(ModelSQL, ModelView):
res['amount'] = self.on_change_with_amount(vals)
return res
def on_change_account(self, values):
account_obj = self.pool.get('account.account')
if values.get('product'):
return {}
taxes = []
result = {
'taxes': taxes,
}
if values.get('account'):
account = account_obj.browse(values['account'])
taxes.extend(tax.id for tax in account.taxes)
return result
def check_modify(self, ids):
'''
Check if the lines can be modified