From 8881e61ec8512e504fcf798519745d73b68b5656 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Tue, 11 Jul 2017 17:18:19 +0200 Subject: [FIX] mail: make many2many_tags_email widget work This widget hasn't been rewritten with the new views. The purpose of this widget is to open a popup for each invalid partners (without email) in a many2many to fill the email. If the email is not set, the partner will not appear in the tags and its id will not be sent (which should not be the role of a widget but that's the way it is). --- addons/web/static/src/js/views/basic/basic_model.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 906464a5a26..c562fa388f0 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -1187,7 +1187,8 @@ var BasicModel = AbstractModel.extend({ } var self = this; - var list = this.localData[record._changes[fieldName] || record.data[fieldName]]; + var localID = (record._changes && record._changes[fieldName]) || record.data[fieldName]; + var list = this.localData[localID]; var field = record.fields[fieldName]; var fieldInfo = record.fieldsInfo[viewType || record.viewType][fieldName]; var view = fieldInfo.views && fieldInfo.views[fieldInfo.mode]; -- cgit v1.2.3 From ed2a77e50e94d957caca6dea309d84c55908cf93 Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Wed, 12 Jul 2017 09:45:46 +0200 Subject: [FIX] web: Fix FieldRadio's o_horizontal/vertical (#18163) --- addons/web/static/src/js/fields/relational_fields.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 567c54abcb1..822955fcf3c 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -1909,7 +1909,7 @@ var FieldRadio = FieldSelection.extend({ this._super.apply(this, arguments); if (this.mode === 'edit') { this.tagName = 'div'; - this.className += this.nodeOptions.horizontal ? 'o_horizontal' : 'o_vertical'; + this.className += this.nodeOptions.horizontal ? ' o_horizontal' : ' o_vertical'; } this.unique_id = _.uniqueId("radio"); this._setValues(); -- cgit v1.2.3 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') 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 +--------- .../web/static/src/js/views/basic/basic_controller.js | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) (limited to 'addons/web/static/src/js') 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'); } }); diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 82dc6f90d26..cc72816a85d 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -250,7 +250,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { on_fail: function (reason) { reload().always(function() { def.reject(reason); - }) + }); }, on_success: def.resolve.bind(def), }); -- cgit v1.2.3 From f2c7e44efe4e2bcdc9c77c66dbd56b8b4cc397b2 Mon Sep 17 00:00:00 2001 From: Khoi Nguyen Date: Thu, 13 Jul 2017 17:40:35 +0200 Subject: [FIX] web: no M2ODialog when pressing enter in a many2one Before this revision, pressing ENTER when inside a many2one field triggers a 'focus out' event. In particular, if one creates a many2one record and uses the ENTER key to click "Create and Edit", two dialog windows appear: one to actually create the associated record, and a second to alert the user that they are creating an associated record. The latter appears every time the many2one field loses focus. This commit changes the 'key up' event for many2one fields to ensure that the ENTER key does not trigger a 'focus out' event. --- addons/web/static/src/js/fields/relational_fields.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 822955fcf3c..14512c02912 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -485,8 +485,16 @@ var FieldMany2One = AbstractField.extend({ }, /** * @private + * + * @param {OdooEvent} ev */ - _onInputKeyup: function () { + _onInputKeyup: function (ev) { + if (ev.which === $.ui.keyCode.ENTER) { + // If we pressed enter, we want to prevent _onInputFocusout from + // executing since it would open a M2O dialog to request + // confirmation that the many2one is not properly set. + return; + } if (this.$input.val() === "") { this.reinitialize(false); } else if (this._getDisplayName(this.m2o_value) !== this.$input.val()) { -- cgit v1.2.3