I have been working on an OpenERP module . The scenario is that I have a selection field containing categories of some assets. I have another field and its associated with an onchange function . Now I want is when my onchange function gets called , the selection field value dynamically set with one of its dropdown values. The selection field is "asset_type" and the other field is "categ_temp2". I tried with the following technique but it didnot work.
<field name="categ_temp2" domain="[('parent_id', '!=', False)]" on_change="mmProduct_Category_OnChange(categ_temp2,asset_type)"/>
def mmProduct_Category_OnChange(self,cr,uid,ids,categ_temp2,asset_type):
for id in ids:
emp = self.pool.get('product.product')
emp.write(cr,uid,ids,{'asset_type', '=', 'phones'})
Plz point my mistake or guide me to solve this. Thanks
I resolved it using the following syntax in my Python code:
def myProduct_Category_OnChange(self,cr,uid,ids,categ_temps):
pro_id=[]
if (str(categ_temps)=='3'):
return {'value':{'asset_type': 'phones'}}
'3' is the id of the categories which is set on the first field (ie categ_temps) By doing this, tha value in the asset_type is selected dynamically when 'catge_temps' is set to id:3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.