Hello to all , I have been trying to use a drop down menu list in my openerp module. I have a many2one field containing categories . This field is associated with an onchange function. This onchange function is returning new values to 2nd field. Now everything is working ok but I want to use a dropdown type menu in the 2nd field so that I can select the values from it. My Python code is as follows:
class deg_form(osv.osv):
_name = "deg.form"
_columns = {
'categ1':fields.many2one('product.category','Parent Category',required=True),
'my_products':fields.char('Product',size=64)
}
def Product_Category_OnChange(self,cr,uid,ids,categ1):
pro_id=[]
cr.execute('select id,name from product_template where categ_id in (select id from product_category where parent_id in (select id from product_category where parent_id='+str(categ1)+')) union select id,name from product_template where categ_id in (select id from product_category where parent_id='+str(categ1)+') union select id,name from product_template where categ_id='+str(categ1))
res = cr.fetchall()
for pid,name in res:
pro_id.append((pid,name))
return {'value':{'my_products':pro_id}}
here is my xml code:
<field name="categ1" on_change="Product_Category_OnChange(categ1)" />
Please help me to achieve this. Thanks n Regards
Hello Arsalan, If my ans is correct, then please approve it.