summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/services/data_manager.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-04-28 12:29:22 +0200
committerAaron Bohy <aab@odoo.com>2017-05-02 15:34:43 +0200
commite9dce2c7b655d0f0b2b1075c05a37a190f1f6473 (patch)
tree031739608caa788116098a8caefcb63c0c1fac51 /addons/web/static/src/js/services/data_manager.js
parentd99ae3fd87aa07a1d7e201dbcd2defd144dfdec3 (diff)
[FIX] web: don't fetch invisible relational fields
Relational fields with attribute 'invisible' set to true are in views because they are used in domains or contexts. In this case their relational data is useless, only their ids matter. Before this rev., their relational data was fetched anyway. More precisely, it was the case for many2ones after a default_get, and for x2manys with inline views, or without view (e.g. with widget 'many2many_tags').
Diffstat (limited to 'addons/web/static/src/js/services/data_manager.js')
-rw-r--r--addons/web/static/src/js/services/data_manager.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/addons/web/static/src/js/services/data_manager.js b/addons/web/static/src/js/services/data_manager.js
index cccad3ddc3f..4786515bb15 100644
--- a/addons/web/static/src/js/services/data_manager.js
+++ b/addons/web/static/src/js/services/data_manager.js
@@ -274,6 +274,24 @@ return core.Class.extend({
field.onChange = "1";
}
+ // the relational data of invisible relational fields should not be
+ // fetched (e.g. name_gets of invisible many2ones), at least those that
+ // are always invisible.
+ // the invisible attribute of a field is supposed to be static ("1" in
+ // general), but not totally as it may use keys of the context
+ // ("context.get('some_key')"). It is evaluated server-side, and the
+ // result is put inside the modifiers as a value of the '(tree_)invisible'
+ // key, and the raw value is left in the invisible attribute (it is used
+ // in debug mode for informational purposes).
+ // this should change, for instance the server might set the evaluated
+ // value in invisible, which could then be seen as static by the client,
+ // and add another key in debug mode containing the raw value.
+ // for now, we do an hack to detect if the value is static and retrieve
+ // it from the modifiers,
+ if (attrs.invisible && attrs.modifiers.match('"(?:tree_)?invisible": ?true')) {
+ attrs.__no_fetch = true;
+ }
+
if (!_.isEmpty(field.views)) {
// process the inner fields_view as well to find the fields they use.
// register those fields' description directly on the view.