diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-04-28 12:29:22 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-05-02 15:34:43 +0200 |
| commit | e9dce2c7b655d0f0b2b1075c05a37a190f1f6473 (patch) | |
| tree | 031739608caa788116098a8caefcb63c0c1fac51 /addons/web/static/src | |
| parent | d99ae3fd87aa07a1d7e201dbcd2defd144dfdec3 (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')
| -rw-r--r-- | addons/web/static/src/js/services/data_manager.js | 18 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 2 |
2 files changed, 19 insertions, 1 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. diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index f3e69a6b453..9bd33b90a3d 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1319,7 +1319,7 @@ var BasicModel = AbstractModel.extend({ // find all many2one related records to be fetched _.each(record.getFieldNames(), function (name) { var field = record.fields[name]; - if (field.type === 'many2one') { + if (field.type === 'many2one' && !record.fieldsInfo[record.viewType][name].__no_fetch) { var localId = (record._changes && record._changes[name]) || record.data[name]; var relatedRecord = self.localData[localId]; if (!relatedRecord) { |
