Add on_change_with on vat_code

Since _inherits children can call parent functions, there is no issue to have
on_change_* function on party
This commit is contained in:
Cédric Krier committed 2010-03-19 15:26:56 +01:00
1 parent 8db04162cc
commit 0c0868410d
1 file changed
+6 -2
+6 -2
View File
@@ -38,8 +38,9 @@ class Party(ModelSQL, ModelView):
vat_country = fields.Selection(VAT_COUNTRIES, 'VAT Country', states=STATES,
help="Setting VAT country will enable validation of the VAT number.",
translate=False)
vat_code = fields.Function(fields.Char('VAT Code'), 'get_vat_code',
searcher='search_vat_code')
vat_code = fields.Function(fields.Char('VAT Code',
on_change_with=['vat_number', 'vat_country']), 'get_vat_code',
searcher='search_vat_code')
addresses = fields.One2Many('party.address', 'party',
'Addresses', states=STATES)
contact_mechanisms = fields.One2Many('party.contact_mechanism', 'party',
@@ -76,6 +77,9 @@ class Party(ModelSQL, ModelView):
context = {}
return context.get('categories', [])
def on_change_with_vat_code(self, cursor, user, vals, context=None):
return (vals.get('vat_country') or '') + (vals.get('vat_number') or '')
def get_vat_code(self, cursor, user, ids, name, context=None):
if not ids:
return []