Odoo Help


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

on 5/16/14, 10:51 AM 2,285 views

I have been working on openerp module development .Today I faced some difficulties while returning dictionary values to a many2one field. I did this thing successfully before but this time I am having some keyerror when try to load openerp server.I checked that my query is working fine and is bringing the exact ids and names but on returning I am getting issue. I am using query to fetch the ids and trying to return them.Here is my code:

def myfunc_name(self,cr,uid,ids,context=None):

domain = [ ]

cr.execute ( ' select id , name from product_category where parent_id is NULL ' )

res = cr.fetchall ( )

for pid,name in res:

         domain.append ( ( pid ) )

         return { ' value ' : { ' categ_temps ' : [ ( ' id ' , ' in ' , domain ) ] } }


Please point me my mistake or guide me so that I can get my work done soon. Regards n Thanks



Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




Sudhir Arya
ERP Harbor Consulting Services
Sudhir Arya (ERP Harbor Consulting Services)
On 5/18/14, 2:22 AM

Your return dictionary is wrong.

If you want to return domain you should return like this: `{ 'domain' : { 'categ_temps' : [ ( 'id' , 'in' , domain ) ] } }

If you want to return value you should return like this: `{ 'value' : { 'categ_temps' : [ ( 'id' , 'in' , domain ) ] } }

You may get more information regarding onchange event: https://doc.openerp.com/6.0/developer/2_6_views_events/events/events/#on-change

You should also know that there is an issue with readonly fields used by the onchange-method. See this bug report:https://bugs.launchpad.net/openobject-client/+bug/378824

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/16/14, 10:51 AM
Seen: 2285 times
Last updated: 3/16/15, 8:10 AM