diff options
| author | Lucas Lefèvre <lul@odoo.com> | 2020-04-22 08:55:55 +0200 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2020-05-26 12:09:51 +0200 |
| commit | 0f01bb70fef98ac8b7501939eb3bec46ff3367ce (patch) | |
| tree | 187f5734996677197408bfabfdd2dc7b547e207e /addons | |
| parent | 4dbab5a70ba02b145396ecc1326ec64cb45c481c (diff) | |
[FIX] project: Allow sub-tasks configuration per project
Enabling sub tasks is done through the general settings
but it should be possible to disable/enable it on specific projects.
The current implementation does not allow that since the field
enabling the feature is a readonly, user dependent field.
Task 2192763
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/project/models/project.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 3cbed1b1107..7e8f86198aa 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -239,7 +239,7 @@ class Project(models.Model): date = fields.Date(string='Expiration Date', index=True, tracking=True) subtask_project_id = fields.Many2one('project.project', string='Sub-task Project', ondelete="restrict", help="Project in which sub-tasks of the current project will be created. It can be the current project itself.") - allow_subtasks = fields.Boolean('Sub-tasks', compute='_compute_allow_subtasks') + allow_subtasks = fields.Boolean('Sub-tasks') # rating fields rating_request_deadline = fields.Datetime(compute='_compute_rating_request_deadline', store=True) @@ -264,10 +264,12 @@ class Project(models.Model): ('project_date_greater', 'check(date >= date_start)', 'Error! project start-date must be lower than project end-date.') ] - def _compute_allow_subtasks(self): - subtask_enabled = self.user_has_groups('project.group_subtask_project') - for project in self: - project.allow_subtasks = subtask_enabled + @api.model + def default_get(self, *args, **kwargs): + defaults = super().default_get(*args, **kwargs) + if 'allow_subtasks' not in defaults: + defaults['allow_subtasks'] = self.env.user.has_group('project.group_subtask_project') + return defaults @api.depends('allowed_internal_user_ids', 'allowed_portal_user_ids') def _compute_allowed_users(self): |
