In my custom module i have two many2one fields ,the data in second many2one field should load dynamically depending upon the value selected in first many2one field ...So for this i called onchange method from first many2one field ,in this function i am setting the domain for second many2one field but i am not getting data with filtered records ????
sample.py
'commodity_name':fields.many2one('commodities.list','Commodity Name'),
'units':fields.many2one('units.list','Units')
def loadDataInSecondBox(self,cr,uid,ids,commodity_name)
cond_val="Here in this variable i am getting particular id/value based on selected commodity name from database through some logic."
domain = {'units': [('basic_unit_id', '=', cond_val)]}
return {'domain': domain}
#res={'quantity':1000000000}
#domain = {'units': [('basic_unit_id', '=', cond_val)]}
#return {'value':res,'domain':domain,'warning':{'title':('Alert'),'message':('hello world,welcome')}}
sample_view.xml
<field name="commodity_name" on_change="loadDataInSecondBox(commodity_name)"/>
<field name="units" />
units.list in py file
class BasicUnitCreation(osv.osv):
_name = "units.list"
_description = "Basic Units Creation"
_columns = {
'name': fields.char('Unit Name', size=64, required=True),
'basic_unit_id':fields.integer('Basic Unit Id',size=3,required=True),
'conversion_value':fields.integer('Conversion Value',size=5,required=True),
}
BasicUnitCreation()