Reputation: 1289
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?
Upvotes: 2
Views: 575
Reputation: 836
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.
Upvotes: 1