gpt4 book ai didi

python - 如何将多个字段传递给搜索功能?在 Odoo 9

转载 作者:太空宇宙 更新时间:2023-11-04 04:58:37 25 4
gpt4 key购买 nike

我想为 View 中的字段设置域。

<record id="view_pack_operation_details_form_extend" model="ir.ui.view">
<field name="name">stock.pack.operation.details.form.extend</field>
<field name="model">stock.pack.operation</field>
<field name="inherit_id" ref="stock.view_pack_operation_details_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='location_dest_id']" position="replace">
<field name="show_all_locations_checkbox"/>
<field name="location_dest_id" domain="[('is_empty', '=', picking_destination_location_id)]"/>
</xpath>
</field>
</record>

我创建了一个搜索函数,但它只接受一个操作数。

is_empty = fields.Boolean(compute='compute_is_empty', search='search_is_empty')


def search_is_empty(self, operator, operand):
ids = []

# I need here the value of show_all_locations_checkbox
show_all_locations = VALUE_OF_CHECKBOX
locations = self.env['stock.location'].search([('location_id', '=', operand)])
for location in locations:
stock_quant = len(self.env['stock.quant'].search([('location_id', '=', location.id)]))
if show_all_locations:
ids.append(location.id)
else:
if stock_quant == 0:
ids.append(location.id)

return [('id', 'in', ids)]

是否有任何选项可以在域操作数中传递多个字段?

最佳答案

您不能传递多个操作数,但您可以使用您传递的数据类型。例如,您可以传递字典/列表而不是传递字段。

关于python - 如何将多个字段传递给搜索功能?在 Odoo 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46403790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com