summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/framework/model.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2016-03-16 09:53:23 +0100
committerAaron Bohy <aab@odoo.com>2016-03-18 10:44:52 +0100
commit002660a9b05cf8620e1c5287a8538ac5e806d59e (patch)
treef113231aa09c7836905510d781f7f23457abfed4 /addons/web/static/src/js/framework/model.js
parent141f4d95bd57f24fb06636a0720cc3665caac39d (diff)
[IMP] openerp, web(_*): batch views RPCs
Load the fields_view of all views of the action together. If a searchview is required, also load its fields_view and its filters. Use lazy-loading for fields as they are required for the Pivot and Graph views only, and may be used by Filters and GroupBy menus of the Search view if the users clicks on 'Add a custom Filter/Group'. The fields are thus also loaded directly if the first view of the action is Pivot or Graph, and otherwise, they are lazy-loaded when/if the user opens a Pivot or Graph view, or if he wants to add a custom Filter/Group. Some refactoring of views API as well: - Views must now be instantiated with their fields_view - Move code requiring fields_view from start() to init(), or willStart() for heavy processing. - Remove view_type attribute from views as it was used to call fields_view_get. - Remove view_id parameter to views' init as it is no longer used. - Move duplicate code from various views' init to the View widget. - Remove view_loading() function from views as they now follow the classical lifecycle of widgets (init -> willStart -> start -> destroy). - Searchview now extends View like all other views. - Remove useless function guard_active() as it was used for the form_view's action buttons to wrap handlers to ensure that they are executed only if the form_view is the current active view. This is not useful anymore as from v9, views and their control panel are appended in the DOM simultaneously, so one can't click on a button of a view which is not the current active view.
Diffstat (limited to 'addons/web/static/src/js/framework/model.js')
-rw-r--r--addons/web/static/src/js/framework/model.js34
1 files changed, 18 insertions, 16 deletions
diff --git a/addons/web/static/src/js/framework/model.js b/addons/web/static/src/js/framework/model.js
index 2621ca490d4..8e37f14218e 100644
--- a/addons/web/static/src/js/framework/model.js
+++ b/addons/web/static/src/js/framework/model.js
@@ -82,29 +82,31 @@ var Model = Class.extend({
* @param {Boolean} [args.toolbar=false] get the toolbar definition
*/
fields_view_get: function (options) {
-
return this.call('fields_view_get', {
view_id: options.view_id,
view_type: options.view_type,
context: options.context,
toolbar: options.toolbar || false
- }).then(function postprocess(fvg) {
- var doc = $.parseXML(fvg.arch).documentElement;
- fvg.arch = utils.xml_to_json(doc, (doc.nodeName.toLowerCase() !== 'kanban'));
- if ('id' in fvg.fields) {
- // Special case for id's
- var id_field = fvg.fields.id;
- id_field.original_type = id_field.type;
- id_field.type = 'id';
- }
- _.each(fvg.fields, function(field) {
- _.each(field.views || {}, function(view) {
- postprocess(view);
- });
+ }).then(this.postprocess_fvg.bind(this));
+ },
+
+ postprocess_fvg: function (fvg) {
+ var self = this;
+ var doc = $.parseXML(fvg.arch).documentElement;
+ fvg.arch = utils.xml_to_json(doc, (doc.nodeName.toLowerCase() !== 'kanban'));
+ if ('id' in fvg.fields) {
+ // Special case for id's
+ var id_field = fvg.fields.id;
+ id_field.original_type = id_field.type;
+ id_field.type = 'id';
+ }
+ _.each(fvg.fields, function(field) {
+ _.each(field.views || {}, function(view) {
+ self.postprocess_fvg(view);
});
- return fvg;
});
- }
+ return fvg;
+ },
});
return Model;