2
Je veux définir un domaine pour un champ dans une vue. J'ai créé une fonction de recherche, mais n'accepte qu'un seul opérande.Comment passer plus d'un champ à une fonction de recherche? Dans Odoo 9
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)]
Y at-il possibilité de passer plus d'un champ dans l'opérande de domaine?
pas vraiment, mais vous pouvez jouer avec le type de données que vous transmettez. Par exemple, au lieu de passer un champ, vous pouvez passer un dictionnaire/liste – dccdany
Bien sûr, merci! – dccdany