0
votes

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?

2

2 Answers

2
votes

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)])

2
votes

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")]