Odoo Help

Welcome!

This community 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.

0

What means "Too many values to unpack" message?

By
Mohammed Osman Gomda
on 4/16/13, 10:23 AM 20,690 views

Can any one give me the cause of the above error message

Some context may help. Anyway, in python normally means you are trying to unpack a tuple with more values repect to target variables. Example: a,b = returnATupleOfMoreThan2Values()

Jethroso
on 4/16/13, 10:39 AM
1

Nicolas Bessi

--Nicolas Bessi--
1590
| 5 7 8
Lausanne, Switzerland
--Nicolas Bessi--
Nicolas Bessi
On 4/16/13, 10:41 AM

It is a Python exception that is the most ofen risen during assignation error: You try to do multiple assignment :

a, b = (1, 2, 3)  #  There is too many value to unpack ;)
a, b = (1, 2)  # That will work
a, b = 'base.main_company'.split('.')  # OK
a, b = 'base.main.company'.split('.')  # KO

In OpenERP it generaly comes when there is a dot in an XML ID. <record id='my.car' ... You should not use the dot when creating an XML ID. It can also be risen when you try to acces an item by his XML id and pass wrong parameters.

That the most common cases but it may also come from any other piece of code...

Regards

Nicolas

0

Priyesh Solanki (pso)

--Priyesh Solanki (pso)--
Tiny ERP Pvt Ltd
http://www.odoo.com
1100
| 2 2 4
--Priyesh Solanki (pso)--
Priyesh Solanki (pso)
On 4/16/13, 10:48 AM

Another case may be regarding looping over dictionary. If one is looping on any dictionary with key and val both without using iteritems(), one will face this error:

a = {'test': 1, 'test 1': 2} 
for k, v in a:
    print k

It will give you that error but instead of one should use it like this:

a = {'test': 1, 'test 1': 2}
for k, v in a.iteritems():
    print k

Still more information can be useful!

Thanks, Priyesh Solanki

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/16/13, 10:23 AM
Seen: 20690 times
Last updated: 3/16/15, 8:10 AM