Select 用户单击复选框时下拉列表中的值? (在同一视图中)Odoo 10
Select a value on a dropbox list when user clicks on a checkbox? (In the same view) Odoo 10
我定义了一个扩展产品视图,它使用复选框字段来定义产品具有某些属性。
我希望当用户单击该复选框时,“度量单位”下拉字段中的给定值会自动 selected。
那么,当用户单击复选框时,我如何 select 下拉列表中的值? (相同的观点)。
谢谢
应该通过onchange方法完成。您可以在该模型中定义新的布尔字段,并且需要为此编写 onchange 函数。
@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)
通过这种方式,您可以在这个布尔字段上发生 onchange 时调用这个函数。
我定义了一个扩展产品视图,它使用复选框字段来定义产品具有某些属性。
我希望当用户单击该复选框时,“度量单位”下拉字段中的给定值会自动 selected。
那么,当用户单击复选框时,我如何 select 下拉列表中的值? (相同的观点)。
谢谢
应该通过onchange方法完成。您可以在该模型中定义新的布尔字段,并且需要为此编写 onchange 函数。
@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)
通过这种方式,您可以在这个布尔字段上发生 onchange 时调用这个函数。