From 99faa6addd245e661fe5af4ffbec74c3fba809a5 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 21 Aug 2015 11:09:25 +0200 Subject: [PATCH] [FIX] web: M2ODialog, adaptation to new Dialog API (backport from the enterprise version) The M2ODialog still used the old Dialog API. --- .../src/js/views/form_relational_widgets.js | 39 +++++++++---------- addons/web/static/src/xml/base.xml | 5 --- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js index 6b4f79541f4..d1d1378b92b 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -26,30 +26,29 @@ var M2ODialog = Dialog.extend({ this._super(parent, { title: _.str.sprintf(_t("Create a %s"), parent.string), size: 'medium', + buttons: [ + {text: _t('Create'), classes: 'btn-primary', click: function() { + if (this.$("input").val() !== ''){ + this.getParent()._quick_create(this.$("input").val()); + this.close(); + } else { + e.preventDefault(); + this.$("input").focus(); + } + }}, + + {text: _t('Create and edit'), classes: 'btn-primary', close: true, click: function() { + this.getParent()._search_create_popup("form", undefined, this.getParent()._create_context(this.$("input").val())); + }}, + + {text: _t('Cancel'), close: true} + ] }); }, start: function() { - var self = this; - var text = _.str.sprintf(_t("You are creating a new %s, are you sure it does not exist yet?"), self.name); - this.$("p").text( text ); - this.$buttons.html(QWeb.render("M2ODialog.buttons")); + var text = _.str.sprintf(_t("You are creating a new %s, are you sure it does not exist yet?"), this.name); + this.$("p").text(text); this.$("input").val(this.getParent().$input.val()); - this.$buttons.find(".oe_form_m2o_qc_button").click(function(e){ - if (self.$("input").val() !== ''){ - self.getParent()._quick_create(self.$("input").val()); - self.destroy(); - } else{ - e.preventDefault(); - self.$("input").focus(); - } - }); - this.$buttons.find(".oe_form_m2o_sc_button").click(function(){ - self.getParent()._search_create_popup("form", undefined, self.getParent()._create_context(self.$("input").val())); - self.destroy(); - }); - this.$buttons.find(".oe_form_m2o_cancel_button").click(function(){ - self.destroy(); - }); }, }); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 7c560c3557f..dc67b36381e 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1380,11 +1380,6 @@ Name: - - - - -