From 3503dd904ecdaa772fc63df7397e948eca3e5c13 Mon Sep 17 00:00:00 2001 From: std-odoo Date: Thu, 8 Sep 2022 11:57:39 +0000 Subject: [PATCH] [IMP] base: remove code redundacy in the properties fields Purpose ======= Remove the code redundacy between convert_to_column and convert_to_cache. Task-2965523 X-original-commit: bbd307d7939319393e3b1782c7200f0010c8c018 Part-of: odoo/odoo#101487 --- odoo/fields.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/odoo/fields.py b/odoo/fields.py index 1506428c41a..fed9f39de98 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -3207,24 +3207,7 @@ class Properties(Field): if not value: return None - if isinstance(value, str): - # assume already JSONified - if not isinstance(json.loads(value), dict): - raise ValueError(f"Wrong property value {value!r}") - return value - - if isinstance(value, dict): - return json.dumps(value) - - if not isinstance(value, list): - raise ValueError(f"Wrong property type {type(value)!r}") - - # Convert the list with all definitions into a simple dict - # {name: value} to store the strict minimum on the child - self._remove_display_name(value) - value = self._list_to_dict(value) - - # the JSON value is sent as a string + value = self.convert_to_cache(value, record, validate=validate) return json.dumps(value) def convert_to_cache(self, value, record, validate=True):