Help

2

[New api]Return a domain in on change

Avatar
Jesús Ventosinos

With the old api we could return a domain in the on change function, is this possible with the new api?

Avatar
Discard
3 Answers
5
Avatar
Jesús Ventosinos
Best Answer

ok, its possible, but if the function has the decorator @api.one not works.

my error:

    @api.one
    @api.onchange('field_id')
     def onchange_field_id(self):
         relation_ids = [x.id for x in self.field_id.relation_ids]
         return {'domain':{'relation_id': [('id', 'in', relation_ids)]}}

but without @api.one works perfectly

    @api.onchange('field_id')
     def onchange_field_id(self):
         relation_ids = [x.id for x in self.field_id.relation_ids]
         return {'domain':{'relation_id': [('id', 'in', relation_ids)]}}

Avatar
Discard
2
Avatar
Deviprasad V
Best Answer

Yes, Its possible an onchange method can return three items (warning, domain, value)

Avatar
Discard
0
Avatar
Sehrish
Best Answer

You can also use @api.multi

Avatar
Discard