如何使用外部 Odoo API 进行过滤?

问题描述 投票:0回答:1

我的代码是这样的

    search_domain = [
    '&',
    ('product_id', '=', 'Product_x'),
    '&',
    ('lot_id', '=', 'AG:04/10/2023:UID520:6666'),

    ('on_hand', '=', True),
]

# Use the search domain to find the specific location
lookuplocationbasedonname = models.execute_kw(db, uid, password, 'stock.quant', 'search_read', [search_domain])
pprint(lookuplocationbasedonname)

搜索返回具有以下内容的 stock.quant 记录。

  'on_hand': False,

我尝试了多种过滤方式,Odoo 文档并没有明确说明过滤方式。

python odoo
1个回答
0
投票

域参数的正确数据类型应该是这样的。

search_domain = [[
    '&',
    ('product_id', '=', 'Product_x'),
    '&',
    ('lot_id', '=', 'AG:04/10/2023:UID520:6666'),
    ('on_hand', '=', True),
]]
© www.soinside.com 2019 - 2024. All rights reserved.