Is it possible to set domain on the python side without putting it in view? I tried to set the domain in the customer field (sale order) based on branch in the Customer menu/template
I have tried this but why it doesn't work ?
@api.onchange('partner_id')
def _onchange_cust_domain(self):
for rec in self:
if self.branch_id.id:
cust_list = rec.partner_id.branch_id.id
return {'domain' : {'partner_id' : [('branch_id', '=', cust_list)]}}
To set the partner_id
domain when the branch_id
field value changes, use the following onchange
function:
Example:
@api.onchange('branch_id')
def onchange_branch_id(self):
if self.branch_id:
return {'domain': {'partner_id': ['|', ('branch_id', '=', False), ('branch_id', '=', self.branch_id.id)]}}
Odoo sets by default the following domain from the python code:
['|', ('company_id', '=', False), ('company_id', '=', company_id)]