summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/view_manager.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2016-03-16 13:55:42 +0100
committerAaron Bohy <aab@odoo.com>2016-03-18 10:44:52 +0100
commit6c57935443d2abd4e3c7507cf4f3093719fb1c2f (patch)
tree88971120ba2505ac90cc8428d57312742e2313bd /addons/web/static/src/js/view_manager.js
parentbda451ab31c19c52eb72c16eae2471d39860a8d3 (diff)
[IMP] openerp,web: cache of actions, fields(_views) and filters
Introduction of 'data_manager' service which handles meta-data related to actions and views (fields_views, fields and filters). Ideally, all RPCs to get that kind of information should go through data_manager, as it holds an internal cache.
Diffstat (limited to 'addons/web/static/src/js/view_manager.js')
-rw-r--r--addons/web/static/src/js/view_manager.js39
1 files changed, 11 insertions, 28 deletions
diff --git a/addons/web/static/src/js/view_manager.js b/addons/web/static/src/js/view_manager.js
index 0996f2c080c..0dfab67b4ea 100644
--- a/addons/web/static/src/js/view_manager.js
+++ b/addons/web/static/src/js/view_manager.js
@@ -3,6 +3,7 @@ odoo.define('web.ViewManager', function (require) {
var ControlPanelMixin = require('web.ControlPanelMixin');
var core = require('web.core');
+var data_manager = require('web.data_manager');
var framework = require('web.framework');
var Model = require('web.DataModel');
var pyeval = require('web.pyeval');
@@ -119,33 +120,24 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
views.push([view.view_id, view.type]);
}
});
- if (this.flags.search_view && !this.search_fields_view) {
- var searchview_id = this.action.search_view_id && this.action.search_view_id[0];
- views.push([searchview_id || false, 'search']);
- }
var options = {
action_id: this.action.id,
- load_fields: load_fields && !this.fields_get_def,
+ load_fields: load_fields,
toolbar: this.flags.sidebar,
};
- return this.dataset._model.call('load_views', {
- views: views,
- options: options,
- context: this.dataset.get_context(),
- }).then(function (result) {
- _.each(result.fields_views, function (fields_view, view_type) {
+ if (this.flags.search_view && !this.search_fields_view) {
+ options.load_filters = true;
+ var searchview_id = this.action.search_view_id && this.action.search_view_id[0];
+ views.push([searchview_id || false, 'search']);
+ }
+ return data_manager.load_views(this.dataset, views, options).then(function (fields_views) {
+ _.each(fields_views, function (fields_view, view_type) {
if (view_type === 'search') {
- self.search_fields_view = self.dataset._model.postprocess_fvg(fields_view);
+ self.search_fields_view = fields_view;
} else {
- self.views[view_type].fields_view = self.dataset._model.postprocess_fvg(fields_view);
+ self.views[view_type].fields_view = fields_view;
}
});
- if (result.filters) {
- self.search_filters = result.filters;
- }
- if (result.fields) {
- self.fields_get_def = $.when(result.fields);
- }
});
},
/**
@@ -158,14 +150,6 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
get_default_view: function() {
return this.views[this.flags.default_view || this.view_order[0].type];
},
- get_fields: function() {
- if (!this.fields_get_def) {
- this.fields_get_def = this.dataset._model.call('fields_get', {
- context: this.dataset.get_context()
- });
- }
- return this.fields_get_def;
- },
switch_mode: function(view_type, view_options) {
var self = this;
var view = this.views[view_type];
@@ -383,7 +367,6 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
$buttons: $("<div>"),
action: this.action,
search_defaults: search_defaults,
- filters: this.search_filters,
};
// Instantiate the SearchView, but do not append it nor its buttons to the DOM as this will
// be done later, simultaneously to all other ControlPanel elements