Odoo Help


TypeError: unhashable type: 'list' while click on dropdown list

Umesh Choudhari
on 2/25/16, 6:12 AM 1,047 views

My .py file is

class orion_specific_product(models.Model):
    _name = 'orion.specific.product'
    name = fields.Char(required=True)
    mfd_pro = fields.Boolean(default=False)
    active = fields.Boolean(default=True)
    sale_ok = fields.Boolean(default=True)
    product_id = fields.Many2one('orion.product.product')
    attribute_id = fields.Many2one('temp.orion.product.attribute')
    attribute_value_id = fields.Many2one('temp.orion.product.attribute.value')
    def _change_mfd_pro(self):
        if self.name:
            if self.mfd_pro == False:
                if len(self.name)>2:
                    self.name = self.name[1:]
            elif self.mfd_pro == True:
                if len(self.name)>2:
                    self.mfd_pro = True
    def _change_product(self):
        if (self.product_id):
            # storing short name in name field
            pro_name = self.product_id.name
                index_value = pro_name.index(' -')
                self.name = pro_name[:index_value]
            except ValueError:
                self.name = pro_name
        #clearing temp table
        self.env.cr.execute("delete from temp_orion_product_attribute")
        #populating data to temp tables
        #1. Attributes
        self.env.cr.execute("""select a.id,a.name from orion_product_attribute a, orion_product_line l where l.att_ids = a.id and l.pro_ids = %s""" %(self.product_id.id))
        rows = self.env.cr.fetchall()
        if rows.count>0:
            for row in rows:
                self.env.cr.execute("""insert into temp_orion_product_attribute(name,a_id) values('%s','%s')""" %(row[1],row[0]))
    def _change_attribute(self):
        if (self.attribute_id):
            #populating data to temp tables
            self.env.cr.execute("""select id from orion_product_line where pro_ids = %s and att_ids = %s""" %(self.product_id.id, self.attribute_id.id))
            row = self.env.cr.fetchone()
            if row:
                self.env.cr.execute("""select v.id,v.name from orion_product_attribute_value v, orion_product_orion_pro_value_rel r where r.line_ids = %s and r.value_ids = v.id""" %(row[0]))
                rows = self.env.cr.fetchall()
                for i in rows:
                    self.env.cr.execute("""insert into temp_orion_product_attribute_value(name,v_id) values('%s','%s')""" %(i[1],i[0]))
                    self.env.cr.execute("""delete from temp_orion_product_attribute where a_id='%s'""" %(self.attribute_id.a_id))

And I got this error:

Traceback (most recent call last):
  File "/opt/odoopro/openerp/http.py", line 537, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/opt/odoopro/openerp/http.py", line 574, in dispatch
    result = self._call_function(**self.params)
  File "/opt/odoopro/openerp/http.py", line 310, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/opt/odoopro/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/opt/odoopro/openerp/http.py", line 307, in checked_call
    return self.endpoint(*a, **kw)
  File "/opt/odoopro/openerp/http.py", line 803, in __call__
    return self.method(*args, **kw)
  File "/opt/odoopro/openerp/http.py", line 403, in response_wrap
    response = f(*args, **kw)
  File "/opt/odoopro/addons/web/controllers/main.py", line 944, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/opt/odoopro/addons/web/controllers/main.py", line 936, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/opt/odoopro/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoopro/openerp/api.py", line 372, in old_api
    result = method(recs, *args, **kwargs)
  File "/opt/odoopro/openerp/models.py", line 1728, in name_search
    return self._name_search(name, args, operator, limit=limit)
  File "/opt/odoopro/openerp/api.py", line 266, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoopro/openerp/api.py", line 508, in new_api
    result = method(self._model, cr, uid, *args, **old_kwargs)
  File "/opt/odoopro/openerp/models.py", line 1740, in _name_search
    ids = self._search(cr, user, args, limit=limit, context=context, access_rights_uid=access_rights_uid)
  File "/opt/odoopro/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoopro/openerp/models.py", line 4674, in _search
    query = self._where_calc(cr, user, args, context=context)
  File "/opt/odoopro/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/odoopro/openerp/models.py", line 4485, in _where_calc
    e = expression.expression(cr, user, domain, self, context)
  File "/opt/odoopro/openerp/osv/expression.py", line 659, in __init__
    self.expression = distribute_not(normalize_domain(exp))
  File "/opt/odoopro/openerp/osv/expression.py", line 308, in distribute_not
TypeError: unhashable type: 'list'

I formatted your code. Make sure the indents I put are correct. In the future, to paste code, just type enter a few times, open your HTML inspector, pick an empty

element, modify it, paste your code and wrap it with

, then hit save.
on 2/25/16, 9:30 AM

wrap it with pre tags (damn !)

on 2/25/16, 9:33 AM

I am new to odoo can you help me please!

Umesh Choudhari
on 2/26/16, 12:22 AM

Akhil P Sivan

--Akhil P Sivan--
| 5 3 7
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 2/26/16, 12:52 AM


Something wrong the logic & indentation of this part:

    def _change_mfd_pro(self):
        if self.name:
            if self.mfd_pro == False:
                if len(self.name)>2:
                    self.name = self.name[1:]
                elif self.mfd_pro == True:
                    if len(self.name)>2:
                        self.mfd_pro = True

I don't know exactly what you are trying to do. Please check n correct it.

Umesh Choudhari
On 2/26/16, 1:59 AM

@Akhil P Sivan

All my indentation are correct

And as per logic i will expain to you:

    def _change_mfd_pro(self):
        if self.name: #checks if name field has value or not
            if self.mfd_pro == False: # checks if the boolean field is false or not
                if len(self.name)>2: # checks the length of characters in the name field 
                    self.name = self.name[1:] # removes the first character
            elif self.mfd_pro == True: # if boolean field is true
                if len(self.name)>2: checks the length and then add 'N' to the start of the value in the name field
                    self.mfd_pro = True

When does the error occurs exactly ? What action are you doing that throw the error ?

on 2/26/16, 3:12 AM

when I click on 'attribute_id' field which is many2one

Umesh Choudhari
on 2/26/16, 3:30 AM

data gets populated after selecting a value from 'product_id' into 'temp.orion.product.attribute' table

Umesh Choudhari
on 2/26/16, 3:33 AM

Found the error it was in domain. In xml file i have given domain="[('pro_id','=','')]"

Umesh Choudhari
on 3/3/16, 11:32 PM

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

2 follower(s)


Asked: 2/25/16, 6:12 AM
Seen: 1047 times
Last updated: 2/26/16, 3:13 AM