diff options
| author | Christophe Simonis <chs@odoo.com> | 2016-09-30 17:23:30 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2016-09-30 17:23:30 +0200 |
| commit | c8cc54559b75a621e4444ecdca6abd901b45e494 (patch) | |
| tree | 92141325d4dbbf70bbfb8e0c040d4435c8d2378f /addons/web/static/src/js/framework/data_manager.js | |
| parent | b2804b1d2ae5fd7ec5c0eca79a8db77476badc84 (diff) | |
| parent | 91a14488250bc2bb405cc6d300359aa272642484 (diff) | |
[MERGE] forward port branch 10.0 up to 91a1448
Diffstat (limited to 'addons/web/static/src/js/framework/data_manager.js')
| -rw-r--r-- | addons/web/static/src/js/framework/data_manager.js | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/addons/web/static/src/js/framework/data_manager.js b/addons/web/static/src/js/framework/data_manager.js index 29d6d585f6a..55a4b4da15b 100644 --- a/addons/web/static/src/js/framework/data_manager.js +++ b/addons/web/static/src/js/framework/data_manager.js @@ -6,9 +6,19 @@ var Model = require('web.DataModel'); var session = require('web.session'); var utils = require('web.utils'); +function traverse(tree, f) { + if (f(tree)) { + _.each(tree.children, function(c) { traverse(c, f); }); + } +} + return core.Class.extend({ init: function () { this.Filters = new Model('ir.filters'); + this._init_cache(); + }, + + _init_cache: function () { this._cache = { actions: {}, fields_views: {}, @@ -19,6 +29,14 @@ return core.Class.extend({ }, /** + * Invalidates the whole cache + * Suggestion: could be refined to invalidate some part of the cache + */ + invalidate: function () { + this._init_cache(); + }, + + /** * Loads an action from its id or xmlid. * * @param {int|string} [action_id] the action id or xmlid @@ -196,19 +214,46 @@ return core.Class.extend({ */ _postprocess_fvg: function (fields_view) { var self = this; + + // Parse and process arch var doc = $.parseXML(fields_view.arch).documentElement; + var fields = fields_view.fields; fields_view.arch = utils.xml_to_json(doc, (doc.nodeName.toLowerCase() !== 'kanban')); + traverse(fields_view.arch, function(node) { + if (typeof node === 'string') { + return false; + } + if (node.tag === 'field') { + fields[node.attrs.name].__attrs = node.attrs; + if (fields[node.attrs.name].type === 'many2one') { // FIXME: this shouldn't be done here + if (node.attrs.widget === 'statusbar' || node.attrs.widget === 'radio') { + fields[node.attrs.name].__fetch_status = true; + } else if (node.attrs.widget === 'selection') { + fields[node.attrs.name].__fetch_selection = true; + } + } + if (node.attrs.widget === 'many2many_checkboxes') { + fields[node.attrs.name].__fetch_many2manys = true; + } + return false; + } + return node.tag !== 'arch'; + }); + + // Special case for id's if ('id' in fields_view.fields) { - // Special case for id's var id_field = fields_view.fields.id; id_field.original_type = id_field.type; id_field.type = 'id'; } + + // Process inner views (one2manys) _.each(fields_view.fields, function(field) { _.each(field.views || {}, function(view) { self._postprocess_fvg(view); }); }); + return fields_view; }, |
