diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 2620e4ed40f..892f1af6ce8 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -46,6 +46,8 @@ instance.web.Notification = instance.web.Widget.extend({ } }); +var opened_modal = []; + instance.web.action_notify = function(element, action) { element.do_notify(action.params.title, action.params.text, action.params.sticky); }; @@ -113,6 +115,8 @@ instance.web.Dialog = instance.web.Widget.extend({ this.init_dialog(); } this.$buttons.insertAfter(this.$dialog_box.find(".modal-body")); + //add to list of currently opened modal + opened_modal.push(this.$dialog_box); return this; }, _add_buttons: function(buttons) { @@ -212,9 +216,13 @@ instance.web.Dialog = instance.web.Widget.extend({ //we need this to put the instruction to remove modal from DOM at the end //of the queue, otherwise it might already have been removed before the modal-backdrop //is removed when pressing escape key - var $parent = this.$el.parents('.modal'); setTimeout(function () { - $parent.remove(); + //remove last modal from list of opened modal since we just destroy it + opened_modal.pop().remove(); + if (opened_modal.length > 0){ + //we still have other opened modal so we should focus it + opened_modal[opened_modal.length-1].focus() + } },0); } this._super(); diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index 2ea29674d8e..b9420a90559 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -205,10 +205,10 @@ instance.web_kanban.KanbanView = instance.web.View.extend({ }); var am = instance.webclient.action_manager; var form = am.dialog_widget.views.form.controller; - form.on("on_button_cancel", am.dialog, am.dialog.close); + form.on("on_button_cancel", am.dialog, function() { return am.dialog.$dialog_box.modal('hide'); }); form.on('record_created', self, function(r) { (new instance.web.DataSet(self, self.group_by_field.relation)).name_get([r]).done(function(new_record) { - am.dialog.close(); + am.dialog.$dialog_box.modal('hide'); var domain = self.dataset.domain.slice(0); domain.push([self.group_by, '=', new_record[0][0]]); var dataset = new instance.web.DataSetSearch(self, self.dataset.model, self.dataset.get_context(), domain);