From d61a88d6f0fe9fcca037a098dce5fc44a11632af Mon Sep 17 00:00:00 2001 From: "Adrien Peiffer (ACSONE)" Date: Wed, 9 Mar 2016 14:14:26 +0100 Subject: [PATCH] [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 | 25 +++++++++++++++++++---- mis_builder/static/src/xml/mis_widget.xml | 3 ++- mis_builder/views/mis_builder.xml | 5 +++-- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/mis_builder/models/mis_builder.py b/mis_builder/models/mis_builder.py index e48c0586..0001552e 100644 --- a/mis_builder/models/mis_builder.py +++ b/mis_builder/models/mis_builder.py @@ -600,7 +600,7 @@ class MisReportInstance(models.Model): 'view_mode': 'form', 'view_type': 'form', 'view_id': view_id.id, - 'target': 'new', + 'target': 'current', } @api.multi @@ -627,6 +627,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 885f42b8..461ba79e 100644 --- a/mis_builder/static/src/js/mis_builder.js +++ b/mis_builder/static/src/js/mis_builder.js @@ -18,13 +18,19 @@ var MisReport = form_common.FormWidget.extend({ 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.generate_content(); }, @@ -56,8 +62,18 @@ var MisReport = form_common.FormWidget.extend({ [self.mis_report_instance_id], {'context': context} ).then(function(result){ - self.do_action(result).done(function(result){ - }); + self.do_action(result); + }); + }, + display_settings: function() { + var self = this + var context = new data.CompoundContext(self.build_context(), self.get_context()|| {}) + new Model("mis.report.instance").call( + "display_settings", + [self.mis_report_instance_id], + {'context': context} + ).then(function(result){ + self.do_action(result); }); }, generate_content: function() { @@ -77,6 +93,7 @@ var MisReport = form_common.FormWidget.extend({ 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 58dce1bb..af55a854 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 @@ +