From e9134c71b60d20da943978d978b09082f8f4d950 Mon Sep 17 00:00:00 2001 From: "Xavier BOL (xbo)" Date: Thu, 26 Aug 2021 09:50:28 +0200 Subject: [PATCH] [IMP] project: remove the create and edit in views of collaborators Before this commit, the project manager could edit the collaborator records. That is, he could change the shared project or the collaborator. This commit allows the user to only see or remove the collaborators for a shared project. If the user wants to add some new collaborators, he has to use the project share wizard. task-2379518 closes #73341 --- addons/project/models/project_collaborator.py | 8 ++++++-- addons/project/views/project_collaborator_views.xml | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/project/models/project_collaborator.py b/addons/project/models/project_collaborator.py index 4315e5a2a9b..223d33155ac 100644 --- a/addons/project/models/project_collaborator.py +++ b/addons/project/models/project_collaborator.py @@ -8,13 +8,17 @@ class ProjectCollaborator(models.Model): _name = 'project.collaborator' _description = 'Collaborators in project shared' - project_id = fields.Many2one('project.project', 'Project Shared', domain=[('privacy_visibility', '=', 'portal')], required=True) - partner_id = fields.Many2one('res.partner', 'Collaborator', required=True) + project_id = fields.Many2one('project.project', 'Project Shared', domain=[('privacy_visibility', '=', 'portal')], required=True, readonly=True) + partner_id = fields.Many2one('res.partner', 'Collaborator', required=True, readonly=True) _sql_constraints = [ ('unique_collaborator', 'UNIQUE(project_id, partner_id)', 'A collaborator cannot be selected more than once in the project sharing access. Please remove duplicate(s) and try again.'), ] + def name_get(self): + collaborator_search_read = self.search_read([('id', 'in', self.ids)], ['id', 'project_id', 'partner_id']) + return [(collaborator['id'], '%s - %s' % (collaborator['project_id'][1], collaborator['partner_id'][1])) for collaborator in collaborator_search_read] + @api.model_create_multi def create(self, vals_list): collaborator = self.env['project.collaborator'].search([], limit=1) diff --git a/addons/project/views/project_collaborator_views.xml b/addons/project/views/project_collaborator_views.xml index 09ebf0173d4..29b48984023 100644 --- a/addons/project/views/project_collaborator_views.xml +++ b/addons/project/views/project_collaborator_views.xml @@ -5,11 +5,11 @@ project.collaborator.view.form project.collaborator -
+ - +
@@ -20,9 +20,9 @@ project.collaborator.view.tree project.collaborator - - + +