diff options
| author | Rémy Baranx (bar) <bar@odoo.com> | 2020-02-26 13:03:10 +0000 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2020-03-19 14:33:02 +0000 |
| commit | 11cd84317d5f40a68d5286ce581ce9c141afcd85 (patch) | |
| tree | c437d34845304abcfeb5019dc635eb2f9e7fc4b8 /addons/pad_project/models | |
| parent | bd2e82b504e17f626e044cbfc2c1e6e39b506ad5 (diff) | |
[IMP] pad_project: collaborative pads in portal
When the 'collaborative pads' option is activated for a project,
and the visibility is set to 'portal users', it is possible to define
the access level to pads to edit task descriptions.
- If set to 'internal users', the behavior stays the same.
- If set to 'portal users', a portal user has access to a pad to edit
task descriptions on the portal.
When configured for portal users access, by default, the task description
is displayed with an 'edit' button on top of it.
On 'edit' button click, the page is re-rendered with an additional
url parmater 'edit=1' to switch to edit mode.
In edit mode, the task description is shown in a collaborative pad,
with a 'Save' button on top of it.
On 'save' button click, the page is re-rendered with the 'edit' url
parameter, to switch in classic mode (read-only).
TaskID: 2204379
[IMP] project: collaborative pads in portal
In order to be (easily) able to add buttons to the right of the description
title, the description title is put inside a d-flex div.
closes odoo/odoo#46591
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/pad_project/models')
| -rw-r--r-- | addons/pad_project/models/project.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/addons/pad_project/models/project.py b/addons/pad_project/models/project.py index 40cfbfdbf10..8c58209a200 100644 --- a/addons/pad_project/models/project.py +++ b/addons/pad_project/models/project.py @@ -11,6 +11,10 @@ class ProjectTask(models.Model): description_pad = fields.Char('Pad URL', pad_content_field='description', copy=False) use_pad = fields.Boolean(related="project_id.use_pads", string="Use collaborative pad", readonly=True) + pad_availability = fields.Selection( + related="project_id.pad_availability", + string="Availability of collaborative pads", + readonly=True) @api.model def create(self, vals): @@ -20,8 +24,37 @@ class ProjectTask(models.Model): self = self.with_context(pad_no_create=True) return super(ProjectTask, self).create(vals) + def _use_portal_pad(self): + """ + Indicates if the task configuration requires to provide + an access to a portal pad. + """ + self.ensure_one() + return self.use_pad and self.pad_availability == 'portal' + + def _get_pad_content(self): + """ + Gets the content of the pad used to edit the task description + and returns it. + """ + self.ensure_one() + return self.pad_get_content(self.description_pad) + class ProjectProject(models.Model): _inherit = "project.project" - use_pads = fields.Boolean("Use collaborative pads", default=True, help="Use collaborative pad for the tasks on this project.") + use_pads = fields.Boolean("Use collaborative pads", default=True, + help="Use collaborative pad for the tasks on this project.") + + pad_availability = fields.Selection([ + ('internal', 'Internal Users'), + ('portal', 'Portal Users') + ], compute='_compute_pad_availability', store=True, readonly=False, + string='Availability of collaborative pads', required=True, default='internal') + + @api.depends('use_pads', 'privacy_visibility') + def _compute_pad_availability(self): + for project in self: + if project.privacy_visibility != 'portal' or not project.use_pads: + project.pad_availability = 'internal' |
