From b88cdfe4d9fdebff9dc4eda15c2dc883c3b3d853 Mon Sep 17 00:00:00 2001 From: "Xavier Bol (xbo)" Date: Tue, 22 Aug 2023 06:12:32 +0000 Subject: [PATCH] [FIX] mail: add missing function `evaluateBooleanExpr` in activity record Before this commit, when the user tries to access to activity view, a traceback is occurred because `ctx.__comp__.evaluateBooleanExpr` is not a function used inside the template of `ActivityRecord`. That function is in fact used in the view compiler but the ActivityRecord component does not have that function defined. This commit defines that function in `ActivityRecord` component to correctly compile its template. Steps to reproduce: ------------------ 1. Install Project 2. Go to Project > Tasks > My Tasks 3. Select the activity view of `project.task` Actual behavior: --------------- A traceback is occurred saying `ctx.__comp__.evaluateBooleanExpr` is not a function. Expected behavior: ----------------- The activity view should be loaded as before. closes odoo/odoo#132610 Signed-off-by: Samuel Degueldre (sad) --- .../src/views/web/activity/activity_record.js | 2 + .../test_mail/static/tests/activity_tests.js | 46 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/addons/mail/static/src/views/web/activity/activity_record.js b/addons/mail/static/src/views/web/activity/activity_record.js index 80b9d8135ce..28e1d65c3ad 100644 --- a/addons/mail/static/src/views/web/activity/activity_record.js +++ b/addons/mail/static/src/views/web/activity/activity_record.js @@ -4,6 +4,7 @@ import { ActivityCompiler } from "@mail/views/web/activity/activity_compiler"; import { Component } from "@odoo/owl"; +import { evaluateBooleanExpr } from "@web/core/py_js/py"; import { useService } from "@web/core/utils/hooks"; import { Field } from "@web/views/fields/field"; import { @@ -25,6 +26,7 @@ export class ActivityRecord extends Component { static template = "mail.ActivityRecord"; setup() { + this.evaluateBooleanExpr = evaluateBooleanExpr; this.user = useService("user"); this.widget = { deletable: false, diff --git a/addons/test_mail/static/tests/activity_tests.js b/addons/test_mail/static/tests/activity_tests.js index f6ee2e14fa2..c055ab792a8 100644 --- a/addons/test_mail/static/tests/activity_tests.js +++ b/addons/test_mail/static/tests/activity_tests.js @@ -77,6 +77,18 @@ QUnit.module("test_mail", {}, function () { "" + "" + "", + "mail.test.activity,1,activity": ` + +
+ + + + + Test invisible + +
+
+ `, }, }; }, @@ -1033,4 +1045,38 @@ QUnit.module("test_mail", {}, function () { "image src is the preview image given in option" ); }); + + QUnit.test("test node is visible with invisible attribute on node", async function (assert) { + const { target, openView } = await start({ + serverData, + }); + await openView({ + res_model: "mail.test.activity", + views: [[1, "activity"]], + }); + + assert.containsN( + target, + ".invisible_node", + 2, + "The node with the invisible attribute should be displayed since the context does not have `invisible` key or has falsy value" + ); + }); + + QUnit.test("test node is not displayed with invisible attribute on node", async function (assert) { + const { target, openView } = await start({ + serverData, + }); + await openView({ + res_model: "mail.test.activity", + views: [[1, "activity"]], + context: { invisible: true }, + }); + + assert.containsNone( + target, + ".invisible_node", + "The node with the invisible attribute should be displayed since `invisible` key in the context contains truly value" + ); + }); });