From e89937c164174ad81c6629bd3551f14d4ec88752 Mon Sep 17 00:00:00 2001 From: "Adrien Peiffer (ACSONE)" Date: Wed, 9 Mar 2016 14:14:26 +0100 Subject: [PATCH 1/4] [IMP][mis_builder] Improve usability : Display directly report instance instead of report instance settings. --- mis_builder/models/mis_builder.py | 17 +++++++++++++- mis_builder/static/src/js/mis_builder.js | 27 ++++++++++++++++++----- mis_builder/static/src/xml/mis_widget.xml | 3 ++- mis_builder/views/mis_builder.xml | 5 +++-- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/mis_builder/models/mis_builder.py b/mis_builder/models/mis_builder.py index 1f6babe6..275847a8 100644 --- a/mis_builder/models/mis_builder.py +++ b/mis_builder/models/mis_builder.py @@ -636,7 +636,7 @@ class MisReportInstance(models.Model): 'view_mode': 'form', 'view_type': 'form', 'view_id': view_id.id, - 'target': 'new', + 'target': 'current', } @api.multi @@ -665,6 +665,21 @@ class MisReportInstance(models.Model): 'context': self.env.context, } + @api.multi + def display_settings(self): + self.ensure_one() + view_id = self.env.ref('mis_builder.mis_report_instance_view_form') + return { + 'type': 'ir.actions.act_window', + 'res_model': 'mis.report.instance', + 'res_id': self.id, + 'view_mode': 'form', + 'view_type': 'form', + 'views': [(view_id.id, 'form')], + 'view_id': view_id.id, + 'target': 'current', + } + @api.multi def compute(self): assert len(self) == 1 diff --git a/mis_builder/static/src/js/mis_builder.js b/mis_builder/static/src/js/mis_builder.js index e23d2a6f..20a83280 100644 --- a/mis_builder/static/src/js/mis_builder.js +++ b/mis_builder/static/src/js/mis_builder.js @@ -7,13 +7,20 @@ openerp.mis_builder = function(instance) { this._super.apply(this, arguments); this.mis_report_data = null; this.mis_report_instance_id = false; + this.field_manager.on("view_content_has_changed", this, this.reload_widget); + }, + + reload_widget: function() { + var self = this + self.mis_report_instance_id = self.getParent().datarecord.id + self.generate_content(); }, start: function() { this._super.apply(this, arguments); var self = this; - self.mis_report_instance_id = self.getParent().dataset.context.active_id - self.getParent().dataset.context['no_destroy'] = true; + self.mis_report_instance_id = self.getParent().datarecord.id + //self.getParent().dataset.context['no_destroy'] = true; self.generate_content(); }, @@ -44,9 +51,18 @@ openerp.mis_builder = function(instance) { [self.mis_report_instance_id], {'context': context} ).then(function(result){ - self.do_action(result).done(function(result){ - a = 2; - }); + self.do_action(result); + }); + }, + display_settings: function() { + var self = this + context = new instance.web.CompoundContext(self.build_context(), self.get_context()|| {}) + new instance.web.Model("mis.report.instance").call( + "display_settings", + [self.mis_report_instance_id], + {'context': context} + ).then(function(result){ + self.do_action(result); }); }, generate_content: function() { @@ -66,6 +82,7 @@ openerp.mis_builder = function(instance) { var self = this; self.$(".oe_mis_builder_print").click(_.bind(this.print, this)); self.$(".oe_mis_builder_export").click(_.bind(this.export_pdf, this)); + self.$(".oe_mis_builder_settings").click(_.bind(this.display_settings, this)); }, events: { "click a.mis_builder_drilldown": "drilldown", diff --git a/mis_builder/static/src/xml/mis_widget.xml b/mis_builder/static/src/xml/mis_widget.xml index a09c653d..9d38b704 100644 --- a/mis_builder/static/src/xml/mis_widget.xml +++ b/mis_builder/static/src/xml/mis_widget.xml @@ -3,7 +3,8 @@
- + +
diff --git a/mis_builder/views/mis_builder.xml b/mis_builder/views/mis_builder.xml index cb117f6f..09074021 100644 --- a/mis_builder/views/mis_builder.xml +++ b/mis_builder/views/mis_builder.xml @@ -120,7 +120,7 @@ mis.report.instance.result.view.form mis.report.instance - +
@@ -139,6 +139,7 @@ + - +
From 2e0967fcee961479923514bc7e7e1d4259aa78e3 Mon Sep 17 00:00:00 2001 From: "Adrien Peiffer (ACSONE)" Date: Wed, 16 Mar 2016 10:16:01 +0100 Subject: [PATCH 4/4] [FIX][mis_builder] Fix the creation of a new mis.report.instance. --- mis_builder/models/mis_builder.py | 4 ++-- mis_builder/static/src/js/mis_builder.js | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/mis_builder/models/mis_builder.py b/mis_builder/models/mis_builder.py index 275847a8..20271920 100644 --- a/mis_builder/models/mis_builder.py +++ b/mis_builder/models/mis_builder.py @@ -667,12 +667,12 @@ class MisReportInstance(models.Model): @api.multi def display_settings(self): - self.ensure_one() + assert len(self._ids) <= 1 view_id = self.env.ref('mis_builder.mis_report_instance_view_form') return { 'type': 'ir.actions.act_window', 'res_model': 'mis.report.instance', - 'res_id': self.id, + 'res_id': self.id if self.id else False, 'view_mode': 'form', 'view_type': 'form', 'views': [(view_id.id, 'form')], diff --git a/mis_builder/static/src/js/mis_builder.js b/mis_builder/static/src/js/mis_builder.js index 1babe907..e0346bd9 100644 --- a/mis_builder/static/src/js/mis_builder.js +++ b/mis_builder/static/src/js/mis_builder.js @@ -13,15 +13,23 @@ openerp.mis_builder = function(instance) { reload_widget: function() { var self = this self.mis_report_instance_id = self.getParent().datarecord.id - self.generate_content(); + if (self.mis_report_instance_id) { + self.generate_content(); + } else { + self.display_settings(); + } }, start: function() { this._super.apply(this, arguments); var self = this; self.mis_report_instance_id = self.getParent().datarecord.id - //self.getParent().dataset.context['no_destroy'] = true; - self.generate_content(); + if (self.mis_report_instance_id) { + self.getParent().dataset.context['no_destroy'] = true; + self.generate_content(); + } else { + self.display_settings(); + } }, get_context: function() {