python - how to get many2one filter value? -


i have following code calender.event inherited class . there create events number sequence . , have other field other fields 'inspection_name' etc

    openerp.osv import fields, osv openerp import api import logging  class feedback_form(osv.model):     _name = 'feedback.form'     _rec_name = 'inspec_type'     _columns={         'folionum' : fields.many2one('calendar.event','maintainace id',),         'folio_number' : fields.many2one('asset.asset','folio number',),         'inspec_type' : fields.many2one('asset1.inspection','inspection type',domain="[('inspec_type' , '=' , folio_number)]"),          'frequency' : fields.char('frequency'),         'shutdown' : fields.char('shout down'),         'insp_msr1' : fields.many2one('results.measure','result',domain="[('inspec_type', '=', inspec_type)]"),     }      def onchange_folio(self, cr, uid, ids, folionum, context=none):         dids = []         record in self.pool.get('calendar.event').browse(cr, uid, folionum, context=context):             dids = [x.id x in record.folio_num]         return {'domain':{'folio_number':[('id','in',dids)]}}      '''def onchange_insp(self, cr, uid, ids, folio_number, context=none):         dids = []         record in self.pool.get('calendar.event').browse(cr, uid, folio_number, context=context):             dids = [x.id x in record.inspection_name]         return {'domain':{'inspec_type':[('id','in',dids)]}}'''      def onchange_measure(self, cr, uid, ids, inspec_type, context=none):         dids = []         record in self.pool.get('asset1.inspection').browse(cr, uid, inspec_type, context=context):             dids = [x.id x in record.msr_insp]         return {'domain':{'insp_msr1':[('id','in',dids)]}} 

calendar.event

from openerp.osv import fields, osv openerp import api

class calendar_event(osv.osv):

_inherit = "calendar.event" _rec_name = 'number'  _columns = {         'number' : fields.char('meeting id',readonly=1),         #'place' : fields.many2one('stock.location','substation location',),          'place' : fields.many2one('asset.parentlocation','substation location',),         #'location' : fields.selection(status_selection,'location',  default='board a'),         'asset_catg_id' : fields.many2one('asset.catg','asset catg selection',),             'area_id' : fields.many2one('asset.name','asset name selection', domain="[('asset_catg_id', '=', asset_catg_id)]", select=true, required=true),         'assetmodelid_add' : fields.many2many('agile.portfolio1','agile_portfolio1_rel','super_id','agile_portfolio1_id','asset model code',),         'folio_num' : fields.many2many('asset.asset','asset_asset_rel','super_id','asset_asset_id','folio num',),         #'inspection_name' : fields.many2one('asset1.inspection','inspection type', ),         'inspection_name' : fields.many2many('asset1.inspection','asset1_inspection_rel','super_id','asset1_inspection_id','inspection type'),         #'folio_num' : fields.related('folio_num','folio_num',string='folio num',relation='asset.asset', type='many2one')             }   _defaults = {             'number' : lambda self,cr,uid,context={}:self.pool.get('ir.sequence').get(cr,uid,'calendar.event'),             } 

first

i guess pretty simple typo mistake have done, statement:

mesure_fil = self.pool.get('calender.event')

should :

mesure_fil = self.pool.get('calendar.event')

you have typo on model name.

second

you need chnage cod eof on_chnage method here make work correctly :

def onchange_folio(self, cr, uid, ids, folionum, context=none):     dids = []     record in self.pool.get('calendar.event').browse(cr, uid, folionum, context=context):             dids = [x.id x in record.inspection_name]     return {'domain':{'inspec_type':[('id','in',dids)]}} 

and in form view please make sure code called this

<field name="folionum" options="{'no_create': true, 'no_open': true}" on_change="onchange_folio(folionum)"/> 

this work correctly.

bests


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -