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/views') 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