[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
This commit is contained in:
Prakash Prajapati
2023-06-19 23:16:45 +02:00
committed by Yash Vaishnav
parent 9df284792c
commit cbc2bf6a3a
2 changed files with 13 additions and 1 deletions
@@ -5,6 +5,10 @@
<field name="model">project.collaborator</field>
<field name="arch" type="xml">
<tree string="Project Collaborators" create="0">
<header>
<button name="%(project_share_wizard_action)d" class="btn-primary" type="action" string="Invite Collaborators"
context="{'default_access_mode': 'edit', 'default_project_id': active_id}" display="always"/>
</header>
<field name="partner_id" options="{'no_create': True}"/>
<field name="partner_email"/>
</tree>
@@ -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',