From 0ee0cb57c2fb4194cebbda7bb6ec24026c32eff3 Mon Sep 17 00:00:00 2001 From: Paul Morelle Date: Fri, 12 Jun 2020 08:18:55 +0000 Subject: [PATCH] [FIX] base: make NameManager.available_fields a dict Until version 13.0, ir.ui.view:postprocess_and_fields returned a tuple of a string and a dict of field information. With aae1d578296875a641d1142c0f73279fc134a151, it now returns a defaultdict instead of the dict. This dict comes from NameManager.available_fields, which is initialized as a defaultdict. There is no apparent reason to have a defaultdict in this place, apart from the usage in has_field. Furthermore, using a defaultdict has a side-effect in the search_view computed field of all the ir.actions.act_window. On a database, if you access env.ref('base.paper_format_action').search_view it will contain a stringified dict, and the string default_dict(, {...}) is used in place of just {...} under the fields key. closes odoo/odoo#53235 X-original-commit: 4586d0fbf0bdd5959b274611c58df911e50f4ef2 Signed-off-by: Olivier Dony (odo) Signed-off-by: Paul Morelle --- odoo/addons/base/models/ir_ui_view.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odoo/addons/base/models/ir_ui_view.py b/odoo/addons/base/models/ir_ui_view.py index 8d9925258c7..356c7bb51f6 100644 --- a/odoo/addons/base/models/ir_ui_view.py +++ b/odoo/addons/base/models/ir_ui_view.py @@ -1842,7 +1842,7 @@ class NameManager: """ An object that manages all the named elements in a view. """ def __init__(self, validate, Model): - self.available_fields = collections.defaultdict(dict) + self.available_fields = dict() self.mandatory_fields = dict() self.mandatory_parent_fields = dict() self.available_actions = set() @@ -1852,7 +1852,7 @@ class NameManager: self.fields_get = self.Model.fields_get() def has_field(self, name, info=()): - self.available_fields[name].update(info) + self.available_fields.setdefault(name, {}).update(info) def has_action(self, name): self.available_actions.add(name)