[FIX] web: CalendarView: event edition in month mode

Fixes the way record end hours are computed in calendar views.

Before this commit:  objects `record start` and `record end` properties being copied by reference
and being incorrectly rewritten by other functions.
This caused incorrect end hour computations (and a SQL crash in the Planning app).

Now, objects are copied by value and don't interfere with each other.

Task 2072961

closes odoo/odoo#37690

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
Julien Mougenot
2019-11-29 09:06:04 +00:00
parent 9d9dc29c3a
commit bf18802c1d
2 changed files with 44 additions and 2 deletions
@@ -707,8 +707,8 @@ return AbstractModel.extend({
'record': evt,
'start': date_start,
'end': date_stop,
'r_start': date_start,
'r_end': date_stop,
'r_start': date_start.clone(),
'r_end': date_stop.clone(),
'title': the_title,
'allDay': all_day,
'id': evt.id,
@@ -2619,6 +2619,48 @@ QUnit.module('Views', {
calendar.destroy();
});
QUnit.test("drag and drop on month mode", async function (assert) {
assert.expect(2);
const calendar = await createCalendarView({
arch:
`<calendar date_start="start" date_stop="stop" mode="month" event_open_popup="true" quick_add="False">
<field name="name"/>
<field name="partner_id"/>
</calendar>`,
archs: archs,
data: this.data,
model: 'event',
View: CalendarView,
viewOptions: { initialDate: initialDate },
});
// Create event (on 20 december)
var $cell = calendar.$('.fc-day-grid .fc-row:eq(3) .fc-day:eq(2)');
testUtils.triggerMouseEvent($cell, "mousedown");
testUtils.triggerMouseEvent($cell, "mouseup");
await testUtils.nextTick();
var $input = $('.modal-body input:first');
await testUtils.fields.editInput($input, "An event");
await testUtils.dom.click($('.modal button.btn-primary'));
await testUtils.nextTick();
// Move event to another day (on 19 december)
await testUtils.dragAndDrop(
calendar.$('.fc-event:contains("An event")'),
calendar.$('.fc-day-grid .fc-row:eq(3) .fc-day-top:eq(1)')
);
await testUtils.nextTick();
await testUtils.dom.click(calendar.$('.fc-event:contains("An event")'));
assert.containsOnce(calendar, '.popover:contains("07:00")',
"start hour shouldn't have been changed");
assert.containsOnce(calendar, '.popover:contains("19:00")',
"end hour shouldn't have been changed");
calendar.destroy();
});
QUnit.test('drag and drop on month mode with date_start and date_delay', async function (assert) {
assert.expect(1);