From b9a9922b62d21ce1eed545937b2b90a5961dae11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 12 Jul 2017 10:46:27 +0200 Subject: [FIX] web: execute action with null active_id instead of undefined Indeed pyeval that evaluates the context explicitly handles null value differently from undefined values. Let us therefore avoid crashes when it manipulates the context. Example of crash * click on forecast in project kanban view without having already created forecasts; * click on 'Assign' to create a new forecast; * selecting a task crashes because of the domain on task field that is evaluated using pyeval with an undefined active_id in context that pyeval cannot handle; --- addons/web/static/src/js/chrome/view_manager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/chrome') diff --git a/addons/web/static/src/js/chrome/view_manager.js b/addons/web/static/src/js/chrome/view_manager.js index 3909a7bfeaa..eeccd9f1085 100644 --- a/addons/web/static/src/js/chrome/view_manager.js +++ b/addons/web/static/src/js/chrome/view_manager.js @@ -558,7 +558,8 @@ var ViewManager = Widget.extend(ControlPanelMixin, { var self = this; var result_handler = on_closed || function () {}; var context = new Context(this.env.context, action_data.context || {}); - var record_id = res_ids && res_ids[0]; + // OR NULL hereunder: pyeval waits specifically for a null value, different from undefined + var record_id = res_ids && res_ids[0] || null; // response handler var handler = function (action) { -- cgit v1.2.3 From 0c496136a9e3eb4dd779e0ac019f1ed9341df152 Mon Sep 17 00:00:00 2001 From: Elkasitu Date: Thu, 13 Jul 2017 11:13:57 +0200 Subject: [FIX] web: Discard from form view to form view Clicking on the discard button in a form view whose previous view is another form view wouldn't do anything. This is fixed by making the view_manager trigger_up a history_back event and then the history_back callback will handle cases in which there is only one view and only one action, which used to be rejected --- addons/web/static/src/js/chrome/action_manager.js | 18 +++++++++++------- addons/web/static/src/js/chrome/view_manager.js | 10 +--------- 2 files changed, 12 insertions(+), 16 deletions(-) (limited to 'addons/web/static/src/js/chrome') diff --git a/addons/web/static/src/js/chrome/action_manager.js b/addons/web/static/src/js/chrome/action_manager.js index 94812302602..4dfc299e428 100644 --- a/addons/web/static/src/js/chrome/action_manager.js +++ b/addons/web/static/src/js/chrome/action_manager.js @@ -420,16 +420,20 @@ var ActionManager = Widget.extend({ return this.inner_widget; }, history_back: function() { - var nb_views = this.inner_action.get_nb_views(); - if (nb_views > 1) { + var nbViews = this.inner_action.get_nb_views(); + if (nbViews > 1) { // Stay on this action, but select the previous view - return this.select_action(this.inner_action, nb_views - 2); + return this.select_action(this.inner_action, nbViews - 2); } - if (this.action_stack.length > 1) { + var nbActions = this.action_stack.length; + if (nbActions > 1) { // Select the previous action - var action = this.action_stack[this.action_stack.length - 2]; - nb_views = action.get_nb_views(); - return this.select_action(action, nb_views - 1); + var action = this.action_stack[nbActions - 2]; + nbViews = action.get_nb_views(); + return this.select_action(action, nbViews - 1); + } + else if (nbActions === 1 && nbViews === 1) { + return this.select_action(this.action_stack[0], 0); } return $.Deferred().reject(); }, diff --git a/addons/web/static/src/js/chrome/view_manager.js b/addons/web/static/src/js/chrome/view_manager.js index eeccd9f1085..fcd823f440a 100644 --- a/addons/web/static/src/js/chrome/view_manager.js +++ b/addons/web/static/src/js/chrome/view_manager.js @@ -636,18 +636,10 @@ var ViewManager = Widget.extend(ControlPanelMixin, { * will call this very view manager to activate the previous view. * @todo: directly switch to previous view * - * A special case is done in the case that there is no previous view. When - * that happens, we simply rerender the current view. - * * @private */ _onSwitchToPreviousView: function () { - if (this.view_stack.length === 1) { - var currentView = this.view_stack[0].controller; - currentView.update({}, {reload: false}); - } else { - this.do_action('history_back'); - } + this.trigger_up('history_back'); } }); -- cgit v1.2.3