diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 9168c1d9e55..785777dfc8c 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -77,6 +77,7 @@ class StockQuant(models.Model): 'stock.lot', 'Lot/Serial Number', index=True, ondelete='restrict', check_company=True, domain=lambda self: self._domain_lot_id()) + lot_properties = fields.Properties(related='lot_id.lot_properties', definition='product_id.lot_properties_definition', readonly=True) sn_duplicated = fields.Boolean(string="Duplicated Serial Number", compute='_compute_sn_duplicated', help="If the same SN is in another Quant") package_id = fields.Many2one( 'stock.quant.package', 'Package', @@ -185,6 +186,14 @@ class StockQuant(models.Model): for quant in self: quant.last_count_date = date_by_quant.get((quant.location_id.id, quant.package_id.id, quant.product_id.id, quant.lot_id.id, quant.owner_id.id)) + def _search(self, domain, *args, **kwargs): + domain = [ + line if not isinstance(line, (list, tuple)) or not line[0].startswith('lot_properties.') + else ['lot_id', 'any', [line]] + for line in domain + ] + return super()._search(domain, *args, **kwargs) + @api.depends('inventory_quantity') def _compute_inventory_diff_quantity(self): for quant in self: diff --git a/addons/stock/views/stock_quant_views.xml b/addons/stock/views/stock_quant_views.xml index b7e4f402567..5a2d462e3df 100644 --- a/addons/stock/views/stock_quant_views.xml +++ b/addons/stock/views/stock_quant_views.xml @@ -28,6 +28,7 @@ + @@ -146,6 +147,7 @@