From 9b7f1c581104bcda02bb33592ae6781b1ba4ac67 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 7 Oct 2011 17:21:16 +0200 Subject: [imp] improved graph view to support o2m (not finished) bzr revid: nicolas.vanhoren@openerp.com-20111007152116-r4ad6z4u035pjxgq --- addons/web_graph/static/src/js/graph.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'addons/web_graph/static/src') diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index ffdec860906..04ebaa8991b 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -17,8 +17,9 @@ QWeb.add_template('/web_graph/static/src/xml/web_graph.xml'); openerp.web.views.add('graph', 'openerp.web_graph.GraphView'); openerp.web_graph.GraphView = openerp.web.View.extend({ - init: function(parent, dataset, view_id) { + init: function(parent, dataset, view_id, options) { this._super(parent); + this.set_default_options(options); this.dataset = dataset; this.view_id = view_id; @@ -37,17 +38,24 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ start: function() { 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('fields_get', []), - this.rpc('/web/view/load', { - model: this.dataset.model, - view_id: this.view_id, - view_type: 'graph' - })).then(function (fields_result, view_result) { + loaded) + .then(function (fields_result, view_result) { self.fields = fields_result[0]; self.fields_view = view_result[0]; self.on_loaded(); - }); + }); }, /** * Returns all object fields involved in the graph view -- cgit v1.2.3 From e2e01eed836941c7bc02362186be6afb67ff6419 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Fri, 7 Oct 2011 18:21:56 +0200 Subject: [imp] mado o2m compatible with graph view bzr revid: nicolas.vanhoren@openerp.com-20111007162156-10r2h2zws40oabnp --- addons/web_graph/static/src/js/graph.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'addons/web_graph/static/src') diff --git a/addons/web_graph/static/src/js/graph.js b/addons/web_graph/static/src/js/graph.js index 04ebaa8991b..bac147b1a91 100644 --- a/addons/web_graph/static/src/js/graph.js +++ b/addons/web_graph/static/src/js/graph.js @@ -28,6 +28,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ this.ordinate = null; this.columns = []; this.group_field = null; + this.is_loaded = $.Deferred(); }, do_show: function () { this.$element.show(); @@ -86,6 +87,7 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ } }, this); this.ordinate = this.columns[0].name; + this.is_loaded.resolve(); }, schedule_chart: function(results) { var self = this; @@ -371,13 +373,16 @@ openerp.web_graph.GraphView = openerp.web.View.extend({ }, do_search: function(domain, context, group_by) { - // TODO: handle non-empty group_by with read_group? - if (!_(group_by).isEmpty()) { - this.abscissa = group_by[0]; - } else { - this.abscissa = this.first_field; - } - this.dataset.read_slice(this.list_fields(), {}, $.proxy(this, 'schedule_chart')); + var self = this; + return $.when(this.is_loaded).pipe(function() { + // TODO: handle non-empty group_by with read_group? + if (!_(group_by).isEmpty()) { + self.abscissa = group_by[0]; + } else { + self.abscissa = self.first_field; + } + return self.dataset.read_slice(self.list_fields(), {}, $.proxy(self, 'schedule_chart')); + }); } }); }; -- cgit v1.2.3