[英]How can I pass more than one field to a search function? In Odoo 9
I want to set a domain for a field in a 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>
I have created a search function, but it only accepts one operand.我创建了一个搜索函数,但它只接受一个操作数。
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)]
Is there any option to pass more than one field in domain operand?是否有任何选项可以在域操作数中传递多个字段?
You can't pass more than one operand, but you can play with the data type you pass.您不能传递多个操作数,但您可以使用传递的数据类型。 For example, instead of passing a field, you can pass a dictionary/list.
例如,您可以传递字典/列表而不是传递字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.