我正在尝试根据以下条件进行搜索:
.search([("product_id", "=", int(product_id)), ("language", "=", language), ['|', ("type", "=", "data"), ("type", "=", "translation")], ])
基本上在给定模型中搜索(它是自定义模型):
product_id
AND language
AND type
列为"data"
或"translation"
但我明白了:
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'>
search
条件是否已正确定义?
答案 0 :(得分:2)
您定义搜索条件的方式不正确。
试试这个
.search(['|', ("type", "=", "data"), ("type", "=", "translation"), ("product_id", "=", int(product_id)), ("language", "=", language)])
答案 1 :(得分:2)
根据documentation, “&” (默认)和“!”是2 arity,所以你可以这样做:
[("product_id", "=", int(product_id)),("language", "=", language),
'|', ("type", "=", "data"), ("type", "=", "translation")]