I am trying to execute a method on an odoo10 server using the xmlrpclib.ServerProxy
. It would load all countries with the name DummyCountry, but only name and id fields. But it throws a TypeError: unhashable type 'list'
. The strange thing is, that this code worked until today. Can someone please explain what is going on?
The line of code with the problem:
# sock is of type xmlrpclib.ServerProxy
countries = sock.execute_kw(
db, # database
uid, # user id
pwd, # password
'res.country', # model
'search_read', # method
[[['name', '=', 'DummyCountry']]], # expressions
{'fields': ['name']} # additional parameters? (id is included automatically)
)
The error:
Traceback (most recent call last):
File "/opt/odoo/odoo10/odoo/service/wsgi_server.py", line 56, in xmlrpc_return
result = odoo.http.dispatch_rpc(service, method, params)
File "/opt/odoo/odoo10/odoo/http.py", line 118, in dispatch_rpc
result = dispatch(method, params)
File "/opt/odoo/odoo10/odoo/service/model.py", line 38, in dispatch
res = fn(db, uid, *params)
File "/opt/odoo/odoo10/odoo/service/model.py", line 119, in wrapper
return f(dbname, *args, **kwargs)
File "/opt/odoo/odoo10/odoo/service/model.py", line 182, in execute
res = execute_cr(cr, uid,obj, method, *args, **kw)
File "/opt/odoo/odoo10/odoo/service/model.py", line 171, in execute_cr
return odoo.api.call_kw(recs, method, args, kw)
File "/opt/odoo/odoo10/odoo/api.py", line 679, in call_kw
return call_kw_model(method, model, args, kwargs)
File "/opt/odoo/odoo10/odoo/api.py", line 664, in call_kw_model
result = method(recs, *args, **kwargs)
File "/opt/odoo/odoo10/odoo/models.py", line 4670, in search_read
records = self.search(domain or [], offset=offset, limit=limit, order=order)
File "/opt/odoo/odoo10/odoo/models.py", line 1509, in search
res = self._search(args, offset=offset,limit=limit, order=order, count=count)
File "/opt/odoo/odoo10/odoo/models.py", line 4215, in _search
query = self._where_calc(args)
File "/opt/odoo/odoo10/odoo/models.py", line 4014, in _where_calc
e = expression.expression(domain, self)
File "/opt/odoo/odoo10/odoo/osv/expression.py", line 640, in __init__
self.expression = distribute_not(normalize_domain(domain))
File "/opt/odoo/odoo10/odoo/osv/expression.py", line 289, in distribute_not
eliftoken in DOMAIN_OPERATORS_NEGATION:
TypeError: unhashable type: 'list'
Try below code.
Output
Hope it will help you.