From ddb8fc1f628433e40ae3196115f7b9a11e5b5254 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Mon, 29 Apr 2019 15:15:35 +0000 Subject: [FIX] web: checkbox in favorites menu: don't close on click Following f4fbaf1efae11e8bd3b1a2938ab765d391764a1b which changes the label/checkbox structure into: ```
``` So, before this commit, there may have been multiple input with the same Id. The consequence is that, when clicking on a label, the browser would take the first Id it found which was erroneous, because all checkboxes in Favorites menu had the same Id In reality, the use case goes as: - open a x2m, - search more - Favorites > Save current search > click on one the two checkboxes > The dropdown closed, without checking the box After this commit, when clicking on the checkbox in the favorites menu the checkbox is toggled and the dropdown stays. Also, the checkboxed have now unique ids OPW 1974587 closes odoo/odoo#33032 Signed-off-by: Lucas Perais (lpe) --- addons/web/static/src/js/chrome/abstract_web_client.js | 14 +++++++++++++- addons/web/static/src/js/chrome/control_panel.js | 5 ----- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/chrome/abstract_web_client.js b/addons/web/static/src/js/chrome/abstract_web_client.js index 7a67d29614f..542b2ebf2b8 100644 --- a/addons/web/static/src/js/chrome/abstract_web_client.js +++ b/addons/web/static/src/js/chrome/abstract_web_client.js @@ -31,7 +31,9 @@ var qweb = core.qweb; var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMixin, { dependencies: ['notification'], - events: _.extend(KeyboardNavigationMixin.events, {}), + events: _.extend({}, KeyboardNavigationMixin.events, { + 'click .o_search_options .dropdown-menu': '_onClickDropDownMenu', + }), custom_events: { clear_uncommitted_changes: function (e) { this.clear_uncommitted_changes().then(e.data.callback); @@ -331,6 +333,16 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMi // Handlers //-------------------------------------------------------------------------- + /** + * When clicking inside a dropdown to modify search options + * prevents the bootstrap dropdown to close on itself + * + * @private + * @param {Event} ev + */ + _onClickDropDownMenu: function (ev) { + ev.stopPropagation(); + }, /** * Whenever the connection is lost, we need to notify the user. * diff --git a/addons/web/static/src/js/chrome/control_panel.js b/addons/web/static/src/js/chrome/control_panel.js index 5d0601820d0..07a6c3bcd70 100644 --- a/addons/web/static/src/js/chrome/control_panel.js +++ b/addons/web/static/src/js/chrome/control_panel.js @@ -100,11 +100,6 @@ var ControlPanel = Widget.extend({ $switch_buttons: this.$('.o_cp_switch_buttons'), }; - // Prevent the search dropdowns to close when clicking inside them - this.$el.on('click.bs.dropdown', '.o_search_options .dropdown-menu', function (e) { - e.stopPropagation(); - }); - // By default, hide the ControlPanel and remove its contents from the DOM this._toggle_visibility(false); -- cgit v1.2.3 From d809b476819968837b61bdd78fbf101caac73adc Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 6 May 2019 15:11:35 +0000 Subject: [FIX] web: month view drop - Install the 'Maintenance' app - Create a maintenance request, set a day and a duration of 6 hours - Go the calendar view, month mode - Move the maintenance request from one day to another The duration is changed with a non-sense value. In month mode, the hours are not represented in the calendar so it is not possible to compute the `date_delay`. Moreover, when a record is moved from one date to another (`_onDropRecord`) in month mode, there is actually no point recomputing the duration; the `date_start` is enough. Note that `date_delay` is used (at the time of writing) in 2 views and absolutely not tested. opw-1984637 closes odoo/odoo#33193 Signed-off-by: Nicolas Martinelli (nim) --- addons/web/static/src/js/views/calendar/calendar_controller.js | 4 +++- addons/web/static/src/js/views/calendar/calendar_model.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js') diff --git a/addons/web/static/src/js/views/calendar/calendar_controller.js b/addons/web/static/src/js/views/calendar/calendar_controller.js index 3bfd40841dd..f90f27a46da 100644 --- a/addons/web/static/src/js/views/calendar/calendar_controller.js +++ b/addons/web/static/src/js/views/calendar/calendar_controller.js @@ -204,7 +204,9 @@ var CalendarController = AbstractController.extend({ * @param {OdooEvent} event */ _onDropRecord: function (event) { - this._updateRecord(event.data); + this._updateRecord(_.extend({}, event.data, { + 'drop': true, + })); }, /** * @private diff --git a/addons/web/static/src/js/views/calendar/calendar_model.js b/addons/web/static/src/js/views/calendar/calendar_model.js index 782f31a1bd2..fa2931a6d19 100644 --- a/addons/web/static/src/js/views/calendar/calendar_model.js +++ b/addons/web/static/src/js/views/calendar/calendar_model.js @@ -105,7 +105,9 @@ return AbstractModel.extend({ } if (this.mapping.date_delay) { - data[this.mapping.date_delay] = (end.diff(start) <= 0 ? end.endOf('day').diff(start) : end.diff(start)) / 1000 / 3600; + if (this.data.scale !== 'month' || (this.data.scale === 'month' && !event.drop)) { + data[this.mapping.date_delay] = (end.diff(start) <= 0 ? end.endOf('day').diff(start) : end.diff(start)) / 1000 / 3600; + } } return data; -- cgit v1.2.3