Reputation: 5496
I have defined an extended product view which uses a checkbox field to define that a product has certain attributes.
I would like that when user clicks on that checkbox a given value in Units of Measure dropdown field is automatically selected.
So, how do I select a value on a dropdown list when user clicks on a checkbox? (same view).
Thanks
Upvotes: 2
Views: 277
Reputation: 14746
It should be done by onchange method. You can define new boolean fields in that model and need to write onchange function for that.
@api.onchange('boolean_field1','boolean_field2')
def onchange_boolean(self):
if self.boolean_field:
self.product_uom_id = product_uom_record_id
else:
self.product_uom_id = product_uom_record_id
#Your custom code
Here,
product_uom_record_id : you need to search product uom record and set it there. Make sure you must assign ID not the object (browsable record)
By this way you can call this function while onchange happen on this boolean field.
Upvotes: 4