diff options
| author | Romeo Fragomeli <rfr@odoo.com> | 2020-03-16 14:57:43 +0000 |
|---|---|---|
| committer | Pierre Paridans <app@odoo.com> | 2020-03-31 15:06:53 +0000 |
| commit | d57470387aa1a155e004aaebec7b8b66de581dcd (patch) | |
| tree | f47332b778256513725161e00600ce7f217b0ce9 /addons/web | |
| parent | 8dfbc7d42148440cb6ede8d291735d92981f8da8 (diff) | |
[FIX] web: calendar's event not correctly ordered in month view
Before this commit, events were sorted by ID in month view.
Event A occurring after event B would be placed on top of B instead
of below.
Steps to reproduce:
* Go in the calendar app
* Insert a event at 12:00
* Insert a event at 8:00
* Insert a event at 14:00
* Go in view month the events are not sorted (BUG)
In month view, events are forced to be "allday", so the sequence used
can't be based on its time but only on its ID.
To fix this, this commit doesn't force the "allday" flag anymore.
Task ID: 2183249
Diffstat (limited to 'addons/web')
3 files changed, 30 insertions, 2 deletions
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 78fa6fdaf5e..caa1d26e8c6 100644 --- a/addons/web/static/src/js/views/calendar/calendar_model.js +++ b/addons/web/static/src/js/views/calendar/calendar_model.js @@ -768,7 +768,6 @@ return AbstractModel.extend({ // allow to resize in month mode r.reset_allday = r.allDay; - r.allDay = true; r.start = date_start.toDate(); r.end = date_stop.startOf('day').toDate(); r.showTime = true; diff --git a/addons/web/static/src/js/views/calendar/calendar_renderer.js b/addons/web/static/src/js/views/calendar/calendar_renderer.js index 17ea9da1333..f6ae085e81a 100644 --- a/addons/web/static/src/js/views/calendar/calendar_renderer.js +++ b/addons/web/static/src/js/views/calendar/calendar_renderer.js @@ -413,7 +413,7 @@ return AbstractRenderer.extend({ if (self.$('.o_cw_popover').length) { self._unselectEvent(); } else { - var data = {start: selectionInfo.start, end: selectionInfo.end}; + var data = {start: selectionInfo.start, end: selectionInfo.end, allDay: selectionInfo.allDay}; if (self.state.context.default_name) { data.title = self.state.context.default_name; } diff --git a/addons/web/static/tests/views/calendar_tests.js b/addons/web/static/tests/views/calendar_tests.js index 9f057a1f0dd..b6debe56f58 100644 --- a/addons/web/static/tests/views/calendar_tests.js +++ b/addons/web/static/tests/views/calendar_tests.js @@ -3370,6 +3370,35 @@ QUnit.module('Views', { calendar.destroy(); }); + + QUnit.test('attempt to create multiples events and the same day and check the ordering on month view', async function (assert) { + assert.expect(3); + /* + This test aims to verify that the order of the event in month view is coherent with their start date. + */ + var initDate = new Date(2020, 2, 12, 8, 0, 0); //12 of March + this.data.event.records = [ + {id: 1, name: "Second event", start: "2020-03-12 05:00:00", stop: "2020-03-12 07:00:00", allday: false}, + {id: 2, name: "First event", start: "2020-03-12 02:00:00", stop: "2020-03-12 03:00:00", allday: false}, + {id: 3, name: "Third event", start: "2020-03-12 08:00:00", stop: "2020-03-12 09:00:00", allday: false}, + ]; + var calendar = await createCalendarView({ + View: CalendarView, + model: 'event', + data: this.data, + arch: `<calendar date_start="start" date_stop="stop" all_day="allday" mode="month" />`, + archs: archs, + viewOptions: { + initialDate: initDate, + }, + }); + assert.ok(calendar.$('.o_calendar_view').find('.fc-view-container').length, "should display in the calendar"); // OK + // Testing the order of the events: by start date + assert.strictEqual(calendar.$('.o_event_title').length, 3, "3 events should be available"); // OK + assert.strictEqual(calendar.$('.o_event_title').first().text(), 'First event', "First event should be on top"); + calendar.destroy(); + }); + }); }); |
