diff --git a/sao/src/model.js b/sao/src/model.js index 6ba77e9fb0..45a47aab55 100644 --- a/sao/src/model.js +++ b/sao/src/model.js @@ -4,7 +4,7 @@ 'use strict'; function get_x2m_sub_fields(f_attrs, prefix) { - if (f_attrs.loading == 'eager' && f_attrs.views) { + if (f_attrs.visible && f_attrs.views) { // There's only one key but we don't know its value const [[, view],] = Object.entries(f_attrs.views); diff --git a/sao/src/view/form.js b/sao/src/view/form.js index ef04fe56d0..a84ba320d6 100644 --- a/sao/src/view/form.js +++ b/sao/src/view/form.js @@ -63,8 +63,8 @@ function eval_pyson(value){ return; } - if (attributes.loading == 'eager') { - this.field_attrs[name].loading = 'eager'; + if (attributes.visible) { + this.field_attrs[name].visible = true; } var WidgetFactory = Sao.View.FormXMLViewParser.WIDGETS[ diff --git a/tryton/tryton/gui/window/view_form/model/record.py b/tryton/tryton/gui/window/view_form/model/record.py index 1e18e690fc..ff00636c2d 100644 --- a/tryton/tryton/gui/window/view_form/model/record.py +++ b/tryton/tryton/gui/window/view_form/model/record.py @@ -15,7 +15,7 @@ logger = logging.getLogger(__name__) def get_x2m_sub_fields(f_attrs, prefix): - if f_attrs['loading'] == 'eager' and f_attrs.get('views'): + if f_attrs.get('visible') and f_attrs.get('views'): sub_fields = functools.reduce( operator.or_, (v.get('fields', {}) for v in f_attrs['views'].values()), diff --git a/tryton/tryton/gui/window/view_form/view/form.py b/tryton/tryton/gui/window/view_form/view/form.py index 5dd2fce445..5939bcb7ee 100644 --- a/tryton/tryton/gui/window/view_form/view/form.py +++ b/tryton/tryton/gui/window/view_form/view/form.py @@ -230,8 +230,8 @@ class FormXMLViewParser(XMLViewParser): self.container.add(None, attributes) return - if attributes.get('loading') == 'eager': - self.field_attrs[name]['loading'] = 'eager' + if int(attributes.get('visible', 0)): + self.field_attrs[name]['visible'] = True widget = self.WIDGETS[attributes['widget']](self.view, attributes) self.view.widgets[name].append(widget) diff --git a/trytond/CHANGELOG b/trytond/CHANGELOG index fa391ffc9c..366925ebfa 100644 --- a/trytond/CHANGELOG +++ b/trytond/CHANGELOG @@ -56,8 +56,8 @@ Version 7.2.0 - 2024-04-29 -------------------------- * Bug fixes (see mercurial logs for details) * Do not accept compressed content from unauthenticated request (#13142) -* Set loading eager to visible xxx2many on form view -* Add loading attribute to form view +* Set visible to visible xxx2many on form view +* Add visible attribute to form view * Add a contextual read limit on Model.read * Add a contextual read limit for related fields * Add xml_id field on ModelStorage diff --git a/trytond/doc/topics/views/index.rst b/trytond/doc/topics/views/index.rst index 07622c7c42..c303190eca 100644 --- a/trytond/doc/topics/views/index.rst +++ b/trytond/doc/topics/views/index.rst @@ -365,9 +365,8 @@ attributes: ``rounded`` or ``circle``. The default value is ``square``. -``loading`` - Override the :attr:`~trytond.model.fields.Field.loading` of the field. - When ``eager`` for :class:`~trytond.model.fields.One2Many` and +``visible`` + When set to ``1`` for :class:`~trytond.model.fields.One2Many` and :class:`~trytond.model.fields.Many2Many` the client may try to read the fields of the related model using dotted notation. This result in less round trip between the client and the server at the diff --git a/trytond/trytond/ir/ui/form.rnc b/trytond/trytond/ir/ui/form.rnc index 82e04caebd..767a2b1b96 100644 --- a/trytond/trytond/ir/ui/form.rnc +++ b/trytond/trytond/ir/ui/form.rnc @@ -121,7 +121,7 @@ attlist.field &= attlist.field &= attribute symbol { text }? attlist.field &= [a:defaultValue = "1"] attribute grouping { "0" | "1" }? attlist.field &= [a:defaultValue = "square"] attribute border { "square" | "circle" | "rounded" }? -attlist.field &= attribute loading { "lazy" | "eager" }? +attlist.field &= [a:defaultValue = "0"] attribute visible { "0" | "1" }? image = element image { attlist.image, empty } attlist.image &= attribute name { text } attlist.image &= [a:defaultValue = "icon"] attribute type { "icon" | "url" }? diff --git a/trytond/trytond/ir/ui/form.rng b/trytond/trytond/ir/ui/form.rng index aca91af5cf..41f85543a8 100644 --- a/trytond/trytond/ir/ui/form.rng +++ b/trytond/trytond/ir/ui/form.rng @@ -579,11 +579,11 @@ - - loading + + visible - lazy - eager + 0 + 1 diff --git a/trytond/trytond/model/modelview.py b/trytond/trytond/model/modelview.py index 4e20803fa1..a5cd20709a 100644 --- a/trytond/trytond/model/modelview.py +++ b/trytond/trytond/model/modelview.py @@ -56,7 +56,7 @@ def set_visible(node, fields, loading='eager'): set_visible(node[0], fields, loading) elif node.tag == 'field': if node.attrib['name'] in fields: - node.attrib['loading'] = 'eager' + node.attrib['visible'] = '1' else: for child in node: set_visible(child, fields, loading) diff --git a/trytond/trytond/tests/test_modelview.py b/trytond/trytond/tests/test_modelview.py index 25f21cd838..58916099de 100644 --- a/trytond/trytond/tests/test_modelview.py +++ b/trytond/trytond/tests/test_modelview.py @@ -60,7 +60,7 @@ class ModelView(TestCase): self.assertEqual( ['OK', 'OK', 'OK', 'OK'], [n.attrib['name'] - for n in group_tree.xpath("//field[@loading='eager']")]) + for n in group_tree.xpath("//field[@visible='1']")]) def test_mark_visible_x2m_notebook(self): "Test marking visible x2m fields in notebook" @@ -108,7 +108,7 @@ class ModelView(TestCase): self.assertEqual( ['OK', 'OK', 'OK', 'OK', 'OK'], [n.attrib['name'] - for n in nb_tree.xpath("//field[@loading='eager']")]) + for n in nb_tree.xpath("//field[@visible='1']")]) def test_mark_visible_x2m_notebook_group(self): "Test marking visible x2m fields in notebook and groups" @@ -176,7 +176,7 @@ class ModelView(TestCase): self.assertEqual( ['OK', 'OK', 'OK', 'OK'], [n.attrib['name'] - for n in ng_tree.xpath("//field[@loading='eager']")]) + for n in ng_tree.xpath("//field[@visible='1']")]) @with_transaction() def test_changed_values(self):