python - i have domain filter code for many2one field. how to do for many2many? -


this working fine many2one field wanted 'area_id' i.e hindu_data_super class should in many2many or please let me know how can select multiple item in 1 field...

class hindu_desh(osv.model):     _name="hindu.desh"      _description="define districts"      _columns={ 'name':fields.char('district name',size=64,required=true) } hindu_desh()    class hindu_state(osv.model):      _name="hindu.state"      _description="define sub districts"      _columns={ 'name':fields.char('sub district name',size=64,required=true), 'hindu_state_id': fields.many2one('hindu.desh','district name',select=true,required=true,ondelete="restrict") } hindu_state()   class hindu_dist(osv.model):      _name="hindu.dist"      _description="define areas"      _columns={ 'name':fields.char('area name',size=64,required=true),         #'area_type': fields.selection(area_type_lov,'area type',required=true),          'hindu_state_id':fields.many2one('hindu.state','sub district name',size=64,required=true),            'district_id':fields.related('hindu_state_id','hindu_state_id',readonly=true,type='many2one',relation='hindu.desh',string='district name'), }  hindu_dist()    class hindu_data_super(osv.model):      _name = "hindu.data.super"      _description = "area of registration super"     _columns = {          'district_id' : fields.many2one('hindu.desh','district', select=true, required=true, ondelete="restrict"),          'hindu_state_id' : fields.many2one('hindu.state', 'sub district', domain="[('hindu_state_id', '=', district_id)]", select=true, required=true),         'area_id' : fields.many2one('hindu.dist', 'area', domain="[('hindu_state_id', '=', hindu_state_id)]", select=true, required=true),     } hindu_data_super() 

i have changed structure of fields please check , try it, , area_ids in hindu.data.super fields.related areas according state selection, if need more think more work required that.

class hindu_desh(osv.model):     _name="hindu.desh"      _description="define districts"      _columns={ 'name':fields.char('district name',size=64,required=true) } hindu_desh()   class hindu_state(osv.model):      _name="hindu.state"      _description="define sub districts"      _columns={              'name':fields.char('sub district name',size=64,required=true),              'hindu_state_id': fields.many2one('hindu.desh','district name',select=true,required=true,ondelete="restrict") }             'area_ids' : fields.one2many('hindu.dist','hindu_state_id','areas') hindu_state()   class hindu_dist(osv.model):      _name="hindu.dist"      _description="define areas"      _columns={          'name':fields.char('area name',size=64,required=true),         'hindu_state_id':fields.many2one('hindu.state','sub district name',size=64,required=true),         'district_id':fields.related('hindu_state_id','hindu_state_id',readonly=true,type='many2one',relation='hindu.desh',string='district name'), }  hindu_dist()    class hindu_data_super(osv.model):      _name = "hindu.data.super"      _description = "area of registration super"     _columns = {          'district_id' : fields.many2one('hindu.desh','district', select=true, required=true, ondelete="restrict"),          'hindu_state_id' : fields.many2one('hindu.state', 'sub district', domain="[('hindu_state_id', '=', district_id)]", select=true, required=true),         'area_ids' : fields.related('hindu_state_id','hindu_state_id',readonly=true,type='one2many',relation='hindu.dist',string='area',store=true),     } hindu_data_super() 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -