From d926d8acfdaaaa334a1859da5fb58455c450edda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 3 Feb 2022 23:05:47 +0100 Subject: [PATCH] Use dictionary as domain for Reference field issue11074 review383911002 --- product.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/product.py b/product.py index 002afc29ec..323446222d 100644 --- a/product.py +++ b/product.py @@ -29,11 +29,22 @@ def classification_tree(name): class Template(metaclass=PoolMeta): __name__ = 'product.template' - classification = fields.Reference('Classification', - selection='get_classification', - domain=[ - ('selectable', '=', True), - ]) + classification = fields.Reference( + "Classification", selection='get_classification') + + @classmethod + def __setup__(cls): + super().__setup__() + for model in cls._get_classification(): + if model in cls.classification.domain: + cls.classification.domain[model] = [ + cls.classification.domain[model], + ('selectable', '=', True), + ] + else: + cls.classification.domain[model] = [ + ('selectable', '=', True), + ] @classmethod def _get_classification(cls):