diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2012-04-05 18:03:15 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2012-04-05 18:03:15 +0200 |
| commit | 9834565c6541edf643d314fc11f70d324238e099 (patch) | |
| tree | 2275023a1d1bcf495302ea321dcb34dc1c31c1da /addons/web_graph/static/src/js/graph.js | |
| parent | 3d01d57c060d8ddd67a610cc1670cee2f723dd17 (diff) | |
[imp] refactoring to allow easy usage of embedded view in any view
bzr revid: nicolas.vanhoren@openerp.com-20120405160315-vn2gawdesxuy53b3
Diffstat (limited to 'addons/web_graph/static/src/js/graph.js')
| -rw-r--r-- | addons/web_graph/static/src/js/graph.js | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index d962c7d6752..287047dc24b 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -17,6 +17,7 @@ var QWeb = openerp.web.qweb, openerp.web.views.add('graph', 'openerp.web_graph.GraphView'); openerp.web_graph.GraphView = openerp.web.View.extend({ display_name: _lt('Graph'), + view_type: "graph", init: function(parent, dataset, view_id, options) { this._super(parent); @@ -39,27 +40,13 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ } this._super(); }, - start: function() { + on_loaded: function(fields_view_get) { var self = this; - this._super(); - var loaded; - if (this.embedded_view) { - loaded = $.when([self.embedded_view]); - } else { - loaded = this.rpc('/web/view/load', { - model: this.dataset.model, - view_id: this.view_id, - view_type: 'graph' - }); - } - return $.when( - this.dataset.call_and_eval('fields_get', [false, {}], null, 1), - loaded) - .then(function (fields_result, view_result) { - self.fields = fields_result[0]; - self.fields_view = view_result[0]; - self.on_loaded(self.fields_view); - }); + self.fields_view = fields_view_get; + return this.dataset.call_and_eval('fields_get', [false, {}], null, 1).pipe(function(fields_result) { + self.fields = fields_result; + return self.on_loaded_2(); + }); }, /** * Returns all object fields involved in the graph view @@ -72,7 +59,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ } return fs; }, - on_loaded: function() { + on_loaded_2: function() { this.chart = this.fields_view.arch.attrs.type || 'pie'; this.orientation = this.fields_view.arch.attrs.orientation || 'vertical'; |
