From cbc2bf6a3a7dc391b90027af53d33f356c90fb21 Mon Sep 17 00:00:00 2001 From: Prakash Prajapati Date: Thu, 18 May 2023 11:51:39 +0000 Subject: [PATCH] [IMP] project: add invite collaborator button to collaborator list view This commit includes the addition of an 'Invite Collaborator' button to the project collaborator list view. When clicked, this button opens the same wizard as the 'Share Editable' button found on the project.project form view. By using this wizard, project collaborators can be added to the responsible project. task-2947578 Part-of: odoo/odoo#119771 --- addons/project/views/project_collaborator_views.xml | 4 ++++ addons/project/wizard/project_share_wizard.py | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/project/views/project_collaborator_views.xml b/addons/project/views/project_collaborator_views.xml index b6e1316ec6a..65aef30273a 100644 --- a/addons/project/views/project_collaborator_views.xml +++ b/addons/project/views/project_collaborator_views.xml @@ -5,6 +5,10 @@ project.collaborator +
+
diff --git a/addons/project/wizard/project_share_wizard.py b/addons/project/wizard/project_share_wizard.py index 0a83e09bfca..d7b39079959 100644 --- a/addons/project/wizard/project_share_wizard.py +++ b/addons/project/wizard/project_share_wizard.py @@ -11,7 +11,15 @@ class ProjectShareWizard(models.TransientModel): @api.model def default_get(self, fields): - result = super().default_get(fields) + # The project share action could be called in `project.collaborator` + # and so we have to check the active_model and active_id to use + # the right project. + active_model = self._context.get('active_model', '') + active_id = self._context.get('active_id', False) + if active_model == 'project.collaborator': + active_model = 'project.project' + active_id = self._context('default_project_id', False) + result = super(ProjectShareWizard, self.with_context(active_model=active_model, active_id=active_id)).default_get(fields) if not result.get('access_mode'): result.update( access_mode='read',