From 51a08fb809ca037a79a030bbe0e036ae4f997f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 4 Jan 2022 22:30:41 +0100 Subject: [PATCH] Set view_id in the context when calling view_attributes issue11091 review364531002 --- CHANGELOG | 1 + doc/ref/models/models.rst | 5 +++++ trytond/model/modelview.py | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 29c8d206f6..46f1873786 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Set view_id in the context when calling view_attributes * Add ip_address and device_cookie login method options * Add support for Python 3.10 * Remove support for Python 3.6 diff --git a/doc/ref/models/models.rst b/doc/ref/models/models.rst index cee32b8086..c5cd06de61 100644 --- a/doc/ref/models/models.rst +++ b/doc/ref/models/models.rst @@ -182,6 +182,11 @@ Class methods: encoded value. If the depends list is set its fields are added to the view if the xpath matches at least one element. +.. note:: + + The``view_id`` is set to the + :attr:`~trytond.transaction.Transaction.context` when calling this method. + .. classmethod:: ModelView.parse_view(tree, type[, field_children[, level[, view_depends]]]) diff --git a/trytond/model/modelview.py b/trytond/model/modelview.py index a06a814cfb..08c5807d2f 100644 --- a/trytond/model/modelview.py +++ b/trytond/model/modelview.py @@ -378,8 +378,9 @@ class ModelView(Model): # Update arch and compute fields from arch parser = etree.XMLParser(remove_blank_text=True) tree = etree.fromstring(result['arch'], parser) - result['arch'], result['fields'] = cls.parse_view( - tree, result['type'], result['field_childs'], level=level) + with Transaction().set_context(view_id=view_id): + result['arch'], result['fields'] = cls.parse_view( + tree, result['type'], result['field_childs'], level=level) cls._fields_view_get_cache.set(key, result) return result