[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
This commit is contained in:
Xavier BOL (xbo)
2021-08-26 16:57:23 +02:00
parent 5d5be956f3
commit e9134c71b6
2 changed files with 10 additions and 6 deletions
@@ -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)
@@ -5,11 +5,11 @@
<field name="name">project.collaborator.view.form</field>
<field name="model">project.collaborator</field>
<field name="arch" type="xml">
<form string="Project Collaborator">
<form string="Project Collaborator" create="0" edit="0">
<sheet>
<group>
<field name="partner_id" options="{'no_create': True}" />
<field name="project_id" options="{'no_create': True}" />
<field name="partner_id" options="{'no_create': True}" />
</group>
</sheet>
</form>
@@ -20,9 +20,9 @@
<field name="name">project.collaborator.view.tree</field>
<field name="model">project.collaborator</field>
<field name="arch" type="xml">
<tree string="Project Collaborators" edit="1" editable="bottom">
<field name="partner_id" options="{'no_create': True}"/>
<tree string="Project Collaborators" create="0">
<field name="project_id" options="{'no_create': True}"/>
<field name="partner_id" options="{'no_create': True}"/>
</tree>
</field>
</record>