Hi all,
I want to implement a default_adress boolean for child partner of company.
I made a boolean field which I added on the contact form (the windows that appears when you click on a kanban item, at the bottom of the parent partner's form)
I defined a onchange function to watch when this field is edited and then if it is set to True I want to set all others at false.
But it does not work. If I write the value on the record, then they are updated only in the database, and not in the UI.
I think I have to deal with the return value of the on change function but I don't know how to reach others childs of the parent.
Hope someone could help.
Here is my code:
default_address = fields.Boolean('Default address')
@api.onchange('default_address')
def onchange_default_address(self):
if self.type in ['delivery', 'invoice']:
if self.default_address is True:
partners = self.search([('type', '=', self.type),
('default_address', '=', True)]) - self
if partners:
res = {
'value': {
'parent_id.child_ids': []
}
}
for partner in partners:
res['value']['parent_id.child_ids'] += (1, partner.id,
{'default_address':
False})
_logger.critical(res)
return res