What I have is two fields on them is customer and the other is customer contact:
customer = fields.Many2one(res.partner)
customer_contact = fields.Many2one(res.partner)
## What I made so far is:
@api.onchange('customer')
def _getCustomerContacts(self):
res = {}
self.customer_contact = False
if self.customer:
res['domain'] = {
'customer_contact': [('id', 'in',
self.carrier.child_ids.ids),('type', '=', 'driver')]}
else:
res['domain'] = {'customer_contact': [('id', 'in', [])]}
return res
This is bad solution for one reason: If i come later to form and try to change only contact, he wont have a domain, and all res partner will be displayed. I searched for answer for a while now and seems like everybody is fine with onchange solution. For me is not fine. So Maybe there would be a nice guy who had similar problem and found solution or maybe you have some suggestion what should I look for.
Thank you very much for your time!!!