M.E.
M.E.

Reputation: 5495

Odoo 10 - Search condition

I am trying to search based on the following condition:

.search([("product_id", "=", int(product_id)), ("language", "=", language), ['|', ("type", "=", "data"), ("type", "=", "translation")], ])

Which basically searchs in a given model (it is a custom one) for:

  1. a given product_id AND
  2. a given language AND
  3. type column being either "data" OR "translation"

But I get:

File "/usr/lib/python2.ion = distribute_not(normalize_domain(domain))\n  
File "/usr/lib/python2.7/dist-packages/odoo/osv/ex
GATION:\nTypeError: unhashable type: \'list\'\n'>

Is the search condition properly defined?

Upvotes: 0

Views: 459

Answers (2)

jahmia
jahmia

Reputation: 65

According to documentation, "&" (default) and "!" are 2 arity, so you can do like this:

[("product_id", "=", int(product_id)),("language", "=", language),
'|', ("type", "=", "data"), ("type", "=", "translation")]

Upvotes: 2

Sanaullah Khan
Sanaullah Khan

Reputation: 46

The way you have defined the search condition is incorrect.

Try this instead

.search(['|', ("type", "=", "data"), ("type", "=", "translation"), ("product_id", "=", int(product_id)), ("language", "=", language)])

Upvotes: 2

Related Questions