From 24684e6dc5b180c73efd3af15d7f95b609dd8d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 21 Oct 2023 01:03:21 +0200 Subject: [PATCH] Allow to search on default UoM of stock lot Since e49aaf8553e1, default UoM of "Lots by Locations" has a searcher using the default UoM of the stock lot. Closes #12583 (grafted from 09a961f1f5e27c8f0787bea29c881ee67c9163a6) --HG-- branch : 6.0 --- modules/stock_lot/stock.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/stock_lot/stock.py b/modules/stock_lot/stock.py index 477a5db293..9f6ca2a74b 100644 --- a/modules/stock_lot/stock.py +++ b/modules/stock_lot/stock.py @@ -79,7 +79,7 @@ class Lot(ModelSQL, ModelView, LotMixin, StockMixin): 'get_quantity', searcher='search_quantity') default_uom = fields.Function( fields.Many2One('product.uom', "Default UOM"), - 'on_change_with_default_uom') + 'on_change_with_default_uom', searcher='search_default_uom') default_uom_digits = fields.Function(fields.Integer("Default Unit Digits"), 'on_change_with_default_uom_digits') @@ -108,6 +108,11 @@ class Lot(ModelSQL, ModelView, LotMixin, StockMixin): if self.product: return self.product.default_uom.id + @classmethod + def search_default_uom(cls, name, clause): + nested = clause[0][len(name):] + return [('product.' + name + nested, *clause[1:])] + @fields.depends('product') def on_change_with_default_uom_digits(self, name=None): if self.product: