From b45d2c96fe85e174e9571b77f61057b908d8fb69 Mon Sep 17 00:00:00 2001 From: "Bastien (bvdn)" Date: Tue, 16 Jan 2024 09:49:17 +0000 Subject: [PATCH] [FIX] web: fix calendar mobile view creation record issue: - calendar mobile view (month) > pressing on a day or timeframe to create a task doesn't work if the view does not have the "day" calendar scale set up Fix: - We are removing the condition preventing the renderer to use the createRecord callback when the view is Mobile and in monthly scale So now a record will be directly created when a user clicks on a timeframe in monthly view even if he's in mobile view Task-3677216 closes odoo/odoo#150624 X-original-commit: da23aa3d68e0f8b833d085c09bcf81d8aa2a4285 Signed-off-by: Aaron Bohy (aab) --- .../calendar_common/calendar_common_renderer.js | 7 ------- .../tests/mobile/views/calendar_view_tests.js | 14 +++++++++----- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js b/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js index 6607e4afc95..8e89fdd201c 100644 --- a/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js +++ b/addons/web/static/src/views/calendar/calendar_common/calendar_common_renderer.js @@ -194,13 +194,6 @@ export class CalendarCommonRenderer extends Component { this.highlightEvent(info.event, "o_cw_custom_highlight"); } onDateClick(info) { - if (this.env.isSmall && this.props.model.scale === "month") { - this.props.model.load({ - date: luxon.DateTime.fromISO(info.dateStr), - scale: "day", - }); - return; - } this.props.createRecord(this.fcEventToRecord(info)); } onDayRender(info) { diff --git a/addons/web/static/tests/mobile/views/calendar_view_tests.js b/addons/web/static/tests/mobile/views/calendar_view_tests.js index 14eae2aeec2..3ee9faac324 100644 --- a/addons/web/static/tests/mobile/views/calendar_view_tests.js +++ b/addons/web/static/tests/mobile/views/calendar_view_tests.js @@ -344,7 +344,7 @@ QUnit.module("Views", ({ beforeEach }) => { assert.verifySteps(["select"]); }); - QUnit.test("calendar (month/year): tap on date switch to day scale", async function (assert) { + QUnit.test("calendar (year): tap on date switch to day scale", async function (assert) { await makeView({ type: "calendar", resModel: "event", @@ -360,6 +360,10 @@ QUnit.module("Views", ({ beforeEach }) => { await tap(target, ".fc-day-top[data-date='2016-02-05']"); await nextTick(); // switch renderer await nextTick(); // await breadcrumb update + assert.strictEqual( + document.querySelector(".o_calendar_container .o_calendar_header h5").textContent, + "5 February 2016" + ); // Should display day view assert.containsNone(target, ".fc-dayGridYear-view"); @@ -382,10 +386,10 @@ QUnit.module("Views", ({ beforeEach }) => { await nextTick(); // await breadcrumb update assert.strictEqual( document.querySelector(".o_calendar_container .o_calendar_header h5").textContent, - "10 February 2016" + "February 2016" ); - assert.containsNone(target, ".fc-dayGridMonth-view"); - assert.containsOnce(target, ".fc-timeGridDay-view"); - assert.equal(target.querySelector(".fc-day-header[data-date]").dataset.date, "2016-02-10"); + + // should open a Quick create modal view in mobile on short tap on date in monthly view + assert.containsOnce(target, ".modal"); }); });