From 48a3241dac009b2385f906d9b1a159926c8f2e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 18 Feb 2025 15:47:04 +0100 Subject: [PATCH] Search on code of replacing products when searching on record name Closes #13879 --- modules/product/product.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/product/product.py b/modules/product/product.py index 24650aaff4..5a01a00925 100644 --- a/modules/product/product.py +++ b/modules/product/product.py @@ -430,6 +430,12 @@ class Product( 'invisible': ~Eval('replaced_by'), }, help="The product replacing this one.") + replacing = fields.One2Many( + 'product.product', 'replaced_by', "Replacing", readonly=True, + states={ + 'invisible': ~Eval('replacing'), + }, + help="The products that this one is replacing.") @classmethod def __setup__(cls): @@ -629,8 +635,8 @@ class Product( ('identifiers.code', operator, code_value, *extra), ('template.name', operator, operand, *extra), ('template.code', operator, code_value, *extra), - ('replaced_by.code', operator, code_value, *extra), - ('replaced_by.identifiers.code', operator, code_value, *extra), + ('replacing.code', operator, code_value, *extra), + ('replacing.identifiers.code', operator, code_value, *extra), ] @staticmethod @@ -709,6 +715,7 @@ class Product( default = default.copy() default.setdefault('suffix_code', None) default.setdefault('code', None) + default.setdefault('replacing') return super().copy(products, default=default) @property