From cafbdda1c0faa63fe2ba35fc5cc6723707c20652 Mon Sep 17 00:00:00 2001 From: "Adrien Peiffer (ACSONE)" Date: Wed, 16 Mar 2016 10:16:01 +0100 Subject: [PATCH] [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 | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mis_builder/models/mis_builder.py b/mis_builder/models/mis_builder.py index 0001552e..17bc7aee 100644 --- a/mis_builder/models/mis_builder.py +++ b/mis_builder/models/mis_builder.py @@ -629,12 +629,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 7f184e00..cbd54f42 100644 --- a/mis_builder/static/src/js/mis_builder.js +++ b/mis_builder/static/src/js/mis_builder.js @@ -24,14 +24,23 @@ var MisReport = form_common.FormWidget.extend({ 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.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() { @@ -94,7 +103,7 @@ var MisReport = form_common.FormWidget.extend({ 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'); + var Users = new Model('res.users'); Users.call('has_group', ['account.group_account_user']).done(function (res) { if (res) { self.$(".oe_mis_builder_settings").show();