diff options
| author | Victor Feyens <vfe@odoo.com> | 2020-07-14 14:32:37 +0000 |
|---|---|---|
| committer | Victor Feyens <vfe@odoo.com> | 2020-07-23 16:38:17 +0000 |
| commit | 5dc8b7bdd8ea8a760d1929333cd8461047e5b4e6 (patch) | |
| tree | a726b57bea6d1f801f802767396e2f7f736725c4 /addons/project/models/project.py | |
| parent | 71ab12840bc787ca486202255cd6faa21281b9e1 (diff) | |
[IMP] *: replace default_get overrides by default attribute on fields.
Leave the generic management of fields default to the orm as much as
possible.
* Default method is not called unless necessary.
* Default values are correctly post-processed by the orm when necessary.
Diffstat (limited to 'addons/project/models/project.py')
| -rw-r--r-- | addons/project/models/project.py | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 6509cac3e25..a8725944b39 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -209,7 +209,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') + allow_subtasks = fields.Boolean('Sub-tasks', default=lambda self: self.env.user.has_group('project.group_subtask_project')) # rating fields rating_request_deadline = fields.Datetime(compute='_compute_rating_request_deadline', store=True) @@ -234,13 +234,6 @@ class Project(models.Model): ('project_date_greater', 'check(date >= date_start)', 'Error! project start-date must be lower than project end-date.') ] - @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 - def _compute_alias_enabled(self): for project in self: project.alias_enabled = project.alias_domain and project.alias_id.alias_name |
