python - OpenERP-7 KeyError: 'id' when returning dictionary values -


i have been working on openerp module development .today faced difficulties while returning dictionary values many2one field. did thing before time having keyerror when try load openerp server.i checked query working fine , bringing exact ids , names on returning getting issue. using query fetch ids , trying return them. python code :

     import time      lxml import etree      openerp.osv import fields, osv      openerp import tools       class deg_form(osv.osv):        _name = "product.product"        _inherit = "product.product"        _columns = {             'categ_temps':fields.many2one('product.category','parent'),                    'categ_temps':fields.function(myfunc_name, type="selection",string="parent", method=true, store=true),               'categ_temp2':fields.many2one('product.category','category'),                    'categ_temp3':fields.many2one('product.category','category'),                     'my_products':fields.many2one('product.product','parent'),              }          def myfunc_name(self,cr,uid,ids,context=none):            domain=[]            cr.execute('select id,name product_category parent_id null')            res=cr.fetchall()            pid,name in res:                domain.append((pid))                print name                return {'value':{'categ_temps':[('id','in',domain)]}}          def product_category_onchange(self,cr,uid,ids,categ_temp2):            pro_id=[]            cr.execute('select id,name product_template  categ_id in (select id product_category parent_id in (select id product_category parent_id='+str(categ_temp2)+'))  union select id,name product_template  categ_id in (select id product_category parent_id='+str(categ_temp2)+') union select id,name product_template categ_id='+str(categ_temp2))            res = cr.fetchall()        pid,name in res:                pro_id.append((pid))            return {'domain':{'my_products':[('id','in',pro_id)]}}         def create_product(self,cr,uid,ids,context):            return{                         'view_type': 'form',                  'view_mode': 'form',                  'res_model': 'product.product',                  'context': "{}",                  'type': 'ir.actions.act_window'}         _defaults = {'name':'.','categ_temps':myfunc_name}        def show_product(self,cr,uid,ids,context):           id in ids:               deg_obj=self.pool.get('product.product').browse(cr,uid,id)               my_id=int(deg_obj.my_products)           return{                 'view_type': 'form',                 'view_mode': 'form',                 'res_model': 'product.product',                 'res_id':my_id,                 'context': "{}",                 'type': 'ir.actions.act_window'}     deg_form() 

the error details listed below:

     client traceback (most recent call last):   file "/home/arsalan/openerp-7.0/openerp/addons/web/http.py", line 195, in dispatch     response["result"] = method(self, **self.params)   file "/home/arsalan/openerp-7.0/openerp/addons/web/controllers/main.py", line 1079, in call_kw     return self._call_kw(req, model, method, args, kwargs)   file "/home/arsalan/openerp-7.0/openerp/addons/web/controllers/main.py", line 1071, in _call_kw     return getattr(req.session.model(model), method)(*args, **kwargs)   file "/home/arsalan/openerp-7.0/openerp/addons/web/session.py", line 43, in proxy     result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw)   file "/home/arsalan/openerp-7.0/openerp/addons/web/session.py", line 31, in proxy_method     result = self.session.send(self.service_name, method, *args)   file "/home/arsalan/openerp-7.0/openerp/addons/web/session.py", line 104, in send     raise xmlrpclib.fault(openerp.tools.ustr(e), formatted_info)   server traceback (most recent call last):   file "/home/arsalan/openerp-7.0/openerp/addons/web/session.py", line 90, in send     return openerp.netsvc.dispatch_rpc(service_name, method, args)   file "/home/arsalan/openerp-7.0/openerp/netsvc.py", line 295, in dispatch_rpc     result = exportservice.getservice(service_name).dispatch(method, params)   file "/home/arsalan/openerp-7.0/openerp/service/web_services.py", line 614, in dispatch     res = fn(db, uid, *params)   file "/home/arsalan/openerp-7.0/openerp/osv/osv.py", line 188, in execute_kw     return self.execute(db, uid, obj, method, *args, **kw or {})   file "/home/arsalan/openerp-7.0/openerp/osv/osv.py", line 131, in wrapper     return f(self, dbname, *args, **kwargs)   file "/home/arsalan/openerp-7.0/openerp/osv/osv.py", line 198, in execute     res = self.execute_cr(cr, uid, obj, method, *args, **kw)   file "/home/arsalan/openerp-7.0/openerp/osv/osv.py", line 185, in execute_cr     return getattr(object, method)(cr, uid, *args, **kw)   file "/home/arsalan/openerp-7.0/openerp/addons/product/product.py", line 234, in name_get     reads = self.read(cr, uid, ids, ['name','parent_id'], context=context)   file "/home/arsalan/openerp-7.0/openerp/osv/orm.py", line 3603, in read     select = map(lambda x: isinstance(x, dict) , x['id'] or x, select)   file "/home/arsalan/openerp-7.0/openerp/osv/orm.py", line 3603, in <lambda>     select = map(lambda x: isinstance(x, dict) , x['id'] or x, select) keyerror: 'id' 

please point me mistake or guide me can work done soon. regards n


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -