summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2019-07-04 13:34:51 +0000
committerAaron Bohy <aab@odoo.com>2019-07-09 07:59:05 +0000
commitea2207afeab8c4d8da6b010aebd99f896e04359b (patch)
treed0911418ee1e59c673750ae68896f660a255949d /addons/web/static/src/js
parent9cab694bf594f6c7c8d795174d9159ac82f526b2 (diff)
[FIX] web: don't close dialog on doAction with target 'new'
Rev. ee44d23 fixed a usability issue: when a doAction is performed from a dialog, it automatically closes the dialog (as the action is rendered in the background, behind the dialog). However, it also closes dialogs when the action has target='new', i.e. when it also opens in a dialog, which is not strictly necessary in this case. This is problematic in mobile for the product configurator widget: in the sale.order form view, the order_line field is displayed as a kanban, and in its form view, the product_(template_)id field has widget product_configurator. When a value is set, it performs a doAction (target="new") to configure the product. The widget listens to the dialog's 'closed' event to update itself. However, with what is done in ee44d23, the x2many form dialog is closed by the DoAction, so the flow doesn't work. This rev. reverts the attempt done in ee44d23, and does something a bit more brutal: as soon as an action is pushed in target 'current' (in the main part of the interface), all dialogs are automatically closed. closes odoo/odoo#34678 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/chrome/action_manager.js4
-rw-r--r--addons/web/static/src/js/core/dialog.js6
-rw-r--r--addons/web/static/src/js/views/form/form_controller.js21
3 files changed, 7 insertions, 24 deletions
diff --git a/addons/web/static/src/js/chrome/action_manager.js b/addons/web/static/src/js/chrome/action_manager.js
index 014aa918e54..3d2dc7a4076 100644
--- a/addons/web/static/src/js/chrome/action_manager.js
+++ b/addons/web/static/src/js/chrome/action_manager.js
@@ -12,7 +12,6 @@ odoo.define('web.ActionManager', function (require) {
var AbstractAction = require('web.AbstractAction');
var concurrency = require('web.concurrency');
var Context = require('web.Context');
-var config = require('web.config');
var core = require('web.core');
var Dialog = require('web.Dialog');
var dom = require('web.dom');
@@ -717,6 +716,9 @@ var ActionManager = Widget.extend({
controller: controller,
});
+ // close all dialogs when the current controller changes
+ core.bus.trigger('close_dialogs');
+
// toggle the fullscreen mode for actions in target='fullscreen'
this._toggleFullscreen();
},
diff --git a/addons/web/static/src/js/core/dialog.js b/addons/web/static/src/js/core/dialog.js
index 8f128b657d9..e3101e52bde 100644
--- a/addons/web/static/src/js/core/dialog.js
+++ b/addons/web/static/src/js/core/dialog.js
@@ -22,8 +22,8 @@ var Dialog = Widget.extend({
custom_events: _.extend({}, Widget.prototype.custom_events, {
focus_control_button: '_onFocusControlButton',
}),
- events: _.extend({} , Widget.prototype.events, {
- 'keydown .modal-footer button':'_onFooterButtonKeyDown',
+ events: _.extend({}, Widget.prototype.events, {
+ 'keydown .modal-footer button': '_onFooterButtonKeyDown',
}),
/**
* @param {Widget} parent
@@ -92,6 +92,8 @@ var Dialog = Widget.extend({
this.backdrop = options.backdrop;
this.renderHeader = options.renderHeader;
this.renderFooter = options.renderFooter;
+
+ core.bus.on('close_dialogs', this, this.destroy.bind(this));
},
/**
* Wait for XML dependencies and instantiate the modal structure (except
diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js
index 827afbb99ed..89477f9c974 100644
--- a/addons/web/static/src/js/views/form/form_controller.js
+++ b/addons/web/static/src/js/views/form/form_controller.js
@@ -14,7 +14,6 @@ var FormController = BasicController.extend({
custom_events: _.extend({}, BasicController.prototype.custom_events, {
bounce_edit: '_onBounceEdit',
button_clicked: '_onButtonClicked',
- do_action: '_onDoAction',
edited_list: '_onEditedList',
open_one2many_record: '_onOpenOne2ManyRecord',
open_record: '_onOpenRecord',
@@ -544,26 +543,6 @@ var FormController = BasicController.extend({
this._discardChanges();
},
/**
- * Destroy subdialog widgets after an action is finished.
- *
- * @param {OdooEvent} ev
- * @private
- */
- _onDoAction: function (ev) {
- var self = this;
- // A priori, different widgets could write on the "on_success" key.
- // Below we ensure that all the actions required by those widgets
- // are executed in a suitable order before every cycle of destruction.
- var callback = ev.data.on_success || function () {};
- ev.data.on_success = function () {
- callback();
- function isDialog (widget) {
- return (widget instanceof Dialog);
- }
- _.invoke(self.getChildren().filter(isDialog), 'destroy');
- };
- },
- /**
* Called when the user clicks on 'Duplicate Record' in the sidebar
*
* @private