Replace loading attribute by visible for loading xxx2Many fields with dotted notation
Override the loading attribute breaks the dependencies between fields. Such xxx2Many becoming eager loading may miss some lazy loading fields which may break the behavior like the domain inversion (which may set the wrong value). Closes #13452
This commit is contained in:
+1
-1
@@ -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);
|
||||
|
||||
|
||||
@@ -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[
|
||||
|
||||
@@ -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()),
|
||||
|
||||
@@ -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)
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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" }?
|
||||
|
||||
@@ -579,11 +579,11 @@
|
||||
</define>
|
||||
<define name="attlist.field" combine="interleave">
|
||||
<optional>
|
||||
<attribute>
|
||||
<name ns="">loading</name>
|
||||
<attribute a:defaultValue="0">
|
||||
<name ns="">visible</name>
|
||||
<choice>
|
||||
<value>lazy</value>
|
||||
<value>eager</value>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
</choice>
|
||||
</attribute>
|
||||
</optional>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user