Odoo 10 - 搜索条件

时间:2018-05-09 15:24:01

标签: odoo odoo-10

我正在尝试根据以下条件进行搜索:

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

基本上在给定模型中搜索(它是自定义模型):

  1. 给定product_id AND
  2. 给定language AND
  3. type列为"data""translation"
  4. 但我明白了:

    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条件是否已正确定义?

2 个答案:

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