diff --git a/mis_builder/models/mis_builder.py b/mis_builder/models/mis_builder.py index 1f6babe6..20271920 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): + 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 if self.id else False, + '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/css/custom.css b/mis_builder/static/src/css/custom.css index 44be83a4..7b1650ad 100644 --- a/mis_builder/static/src/css/custom.css +++ b/mis_builder/static/src/css/custom.css @@ -11,3 +11,7 @@ /* underline links on hover to give a visual cue */ text-decoration: underline; } + +.openerp .oe_mis_builder_buttons { + padding-bottom: 10px; +} diff --git a/mis_builder/static/src/js/mis_builder.js b/mis_builder/static/src/js/mis_builder.js index e23d2a6f..e0346bd9 100644 --- a/mis_builder/static/src/js/mis_builder.js +++ b/mis_builder/static/src/js/mis_builder.js @@ -7,14 +7,29 @@ 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 + 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().dataset.context.active_id - self.getParent().dataset.context['no_destroy'] = true; - self.generate_content(); + self.mis_report_instance_id = self.getParent().datarecord.id + if (self.mis_report_instance_id) { + self.getParent().dataset.context['no_destroy'] = true; + self.generate_content(); + } else { + self.display_settings(); + } }, get_context: function() { @@ -44,9 +59,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 +90,13 @@ 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)); + var Users = new instance.web.Model('res.users'); + Users.call('has_group', ['account.group_account_user']).done(function (res) { + if (res) { + self.$(".oe_mis_builder_settings").show(); + } + }); }, 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..44c8ec19 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 @@ +