From a32a7d2957ece0994a7c7f7b9a64d3fcc1c1267c Mon Sep 17 00:00:00 2001 From: "Bastien (bvdn)" Date: Wed, 26 Apr 2023 12:24:05 +0000 Subject: [PATCH] [FIX] project: avoid traceback on stat button click - steps to reproduce bug: In project.task sharing form view, When clicking on any of the stat buttons (subtasks or parent task) when you arrive on the actual task formview a MissingError saying 'missing record' appears - Issue: The record loads accordingly but the Missing Error shouldn't appear - Cause: It is coming from the project_sharing_form_compiler which gave the projectSharingId props to the ChatterContainer element but the projectSharingId is equal to the "props.record.context.active_id" of the action, and in the context of the chatter we want the active_id to be equal to the project_id, which was the case when we are coming from the KanbanView and sub-list views but when coming from the task stat button the active_id is equal to the task_id and the env can't find the document 'project.project' with the id of the task. (in portal.py _document_check_access()) - Fix: We simply change the projectSharingId to take the "props.record.contect.active_id_chatter" the give an active_id_chatter= active_id in the Project Sharing task_action which will always equal the Id of the project Task-3284755 closes odoo/odoo#126092 X-original-commit: 22c0825b70bbe8234dee57060bdd5640001f74d7 Signed-off-by: Xavier Bol (xbo) --- addons/project/models/project_project.py | 1 + .../views/form/project_sharing_form_compiler.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/project/models/project_project.py b/addons/project/models/project_project.py index de12d14ffe2..576ae434fa7 100644 --- a/addons/project/models/project_project.py +++ b/addons/project/models/project_project.py @@ -579,6 +579,7 @@ class Project(models.Model): action['context'] = { 'default_project_id': self.id, 'delete': False, + 'active_id_chatter': self.id, } action['display_name'] = self.name return action diff --git a/addons/project/static/src/project_sharing/views/form/project_sharing_form_compiler.js b/addons/project/static/src/project_sharing/views/form/project_sharing_form_compiler.js index ee9c8b0386a..8e325e96574 100644 --- a/addons/project/static/src/project_sharing/views/form/project_sharing_form_compiler.js +++ b/addons/project/static/src/project_sharing/views/form/project_sharing_form_compiler.js @@ -65,7 +65,7 @@ export class ProjectSharingChatterCompiler extends ViewCompiler { return compileChatter(node, { resId: '__comp__.model.root.resId or undefined', resModel: '__comp__.model.root.resModel', - projectSharingId: '__comp__.model.root.context.active_id', + projectSharingId: '__comp__.model.root.context.active_id_chatter', }); } } @@ -76,7 +76,7 @@ registry.category("form_compilers").add("portal_chatter_compiler", { compileChatter(node, { resId: "__comp__.props.record.resId or undefined", resModel: "__comp__.props.record.resModel", - projectSharingId: "__comp__.props.record.context.active_id", + projectSharingId: "__comp__.props.record.context.active_id_chatter", }), });