From 75481e2db00862f1b5a6ae16a5db055477ba34c7 Mon Sep 17 00:00:00 2001 From: "Julien Carion (juca)" Date: Thu, 6 Jul 2023 13:22:32 +0000 Subject: [PATCH] [FIX] web: fix project calendar display name This commit removes the displayName variable of the calendar controller since it wasn't used anymore and the extension of the displayName is now updated in the ProjectCalendarController instead. This fixes an issue in project where the extension of the displayName in the project calendar controller ( - Tasks by Deadline) would not be shown in the view. opw-3410987 closes odoo/odoo#128461 X-original-commit: 120ab2513b487d0c117e5c67ed76e6d154d0243f Signed-off-by: Mathieu Duckerts-Antoine (dam) --- .../project_calendar_controller.js | 2 +- .../project_task_calendar_view_tests.js | 53 +++++++++++++++++++ .../src/views/calendar/calendar_controller.js | 2 - 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 addons/project/static/tests/views/project_task_calendar/project_task_calendar_view_tests.js diff --git a/addons/project/static/src/views/project_calendar/project_calendar_controller.js b/addons/project/static/src/views/project_calendar/project_calendar_controller.js index 24e61059f9c..c43cc6e50b8 100644 --- a/addons/project/static/src/views/project_calendar/project_calendar_controller.js +++ b/addons/project/static/src/views/project_calendar/project_calendar_controller.js @@ -10,6 +10,6 @@ export class ProjectCalendarController extends CalendarController { }; setup() { super.setup(...arguments); - this.displayName += this.env._t(" - Tasks by Deadline"); + this.env.config.setDisplayName(this.env.config.getDisplayName() + this.env._t(" - Tasks by Deadline")); } } diff --git a/addons/project/static/tests/views/project_task_calendar/project_task_calendar_view_tests.js b/addons/project/static/tests/views/project_task_calendar/project_task_calendar_view_tests.js new file mode 100644 index 00000000000..ac86be0313c --- /dev/null +++ b/addons/project/static/tests/views/project_task_calendar/project_task_calendar_view_tests.js @@ -0,0 +1,53 @@ +/** @odoo-module **/ + +import { createWebClient, doAction } from "@web/../tests/webclient/helpers"; +let serverData; +QUnit.module("Project Task Calendar View", (hooks) => { + hooks.beforeEach(() => { + serverData = { + models: { + "project.task": { + fields: { + start: { string: "Date Start", type: "date" }, + stop: { string: "Date End", type: "date" }, + }, + records: [ + { + id: 1, + start: "2017-01-25", + stop: "2017-01-26", + }, { + id: 2, + start: "2017-01-02", + stop: "2017-01-03", + }, + ], + methods: { + check_access_rights: function () { + return Promise.resolve(true); + } + } + }, + }, + } + }); + QUnit.test("breadcrumb contains 'Tasks by deadline'", async function (assert) { + serverData.views = { + "project.task,1,calendar": ``, + "project.task,false,search": ``, + }; + serverData.actions = { + 1: { + id: 1, + name: "test", + res_model: "project.task", + type: "ir.actions.act_window", + views: [[1, "calendar"]], + context: {}, + }, + }; + const webClient = await createWebClient({ serverData }); + await doAction(webClient, 1); + assert.equal(document.querySelector(".o_last_breadcrumb_item span").textContent, 'test - Tasks by Deadline'); + }); +}); diff --git a/addons/web/static/src/views/calendar/calendar_controller.js b/addons/web/static/src/views/calendar/calendar_controller.js index 42f9e6ec4f9..d71a9fcebdb 100644 --- a/addons/web/static/src/views/calendar/calendar_controller.js +++ b/addons/web/static/src/views/calendar/calendar_controller.js @@ -51,7 +51,6 @@ export class CalendarController extends Component { }, { onWillStart: this.onWillStartModel.bind(this), }); - this.displayName = this.env.config.getDisplayName(); useSetupView({ getLocalState: () => this.model.exportedState, @@ -71,7 +70,6 @@ export class CalendarController extends Component { deleteRecord: this.deleteRecord.bind(this), editRecord: this.editRecord.bind(this), setDate: this.setDate.bind(this), - displayName: this.displayName, }; } get containerProps() {