I would like to restrict a many2one(res.partner) fields to show only values belonging to a given partner category.
If I would know the category id, then I could add this to my view:
<field name="insurer" domain="[('category_id', 'in', 1)]"/>
Unfortunately, I don't know the category id, but I create it inside my data xml.
As a result my best idea until now is to define an onchange handler, that sets the domain.
def onchange_insurance(self, cr, uid, ids, first_field):
biztosito_category = self.pool.get('ir.model.data').get_object(cr, uid, 'ensure_base', 'biztosito_partner_category').id
return {
'domain': {
'insurer': [('category_id', '=', biztosito_category)],
},
}
Is there a way to have such a computed domain into the view code without an onchange handler?