File: project_share_collaborator_wizard.py

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (43 lines) | stat: -rw-r--r-- 1,680 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import api, fields, models


class ProjectSharingCollaboratorWizard(models.TransientModel):
    _name = 'project.share.collaborator.wizard'
    _description = 'Project Sharing Collaborator Wizard'

    parent_wizard_id = fields.Many2one(
        'project.share.wizard',
        export_string_translation=False,
    )
    partner_id = fields.Many2one(
        'res.partner',
        string='Collaborator',
        required=True,
    )
    access_mode = fields.Selection(
        [('read', 'Read'), ('edit_limited', 'Edit with limited access'), ('edit', 'Edit')],
        default='read',
        required=True,
        help="Read: collaborators can view tasks but cannot edit them.\n"
            "Edit with limited access: collaborators can view and edit tasks they follow in the Kanban view.\n"
            "Edit: collaborators can view and edit all tasks in the Kanban view. Additionally, they can choose which tasks they want to follow."
    )
    send_invitation = fields.Boolean(
        string='Send Invitation',
        compute='_compute_send_invitation',
        store=True,
        readonly=False,
        default=True,
    )

    @api.depends('partner_id', 'access_mode')
    def _compute_send_invitation(self):
        project = self.parent_wizard_id.resource_ref
        for collaborator in self:
            if (
                collaborator.partner_id not in project.message_partner_ids
                or (collaborator.access_mode != 'read' and collaborator.partner_id not in project.collaborator_ids.partner_id)
            ):
                collaborator.send_invitation = True