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