This change ensures that when the user activates optional features of the project app, they are enabled in existing projects as well as newly created projects automatically, which is likely what the user expects. For most optional features, this behavior was already in place. It was not in place yet for the sub-tasks and timesheets features, which this change fixes. Two added tests check the behavior described above for features that are activated through a `group_*` field on `res.config.settings` (sub-tasks, recurring tasks and ratings). The tests do not cover features that are activated through a `module_*` field, as such fields require the installation of further modules and we cannot simulate this. Task 2297054 closes odoo/odoo#60106 X-original-commit: 8dd0edae898a532dbe7e4f18c9118b9b68e57900 Related: odoo/enterprise#14119 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com> Co-authored-by: Kevin Baptiste <50135801+kba-odoo@users.noreply.github.com>
34 lines
1.5 KiB
Python
34 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class ResConfigSettings(models.TransientModel):
|
|
_inherit = 'res.config.settings'
|
|
|
|
module_project_forecast = fields.Boolean(string="Planning")
|
|
module_hr_timesheet = fields.Boolean(string="Task Logs")
|
|
group_subtask_project = fields.Boolean("Sub-tasks", implied_group="project.group_subtask_project")
|
|
group_project_rating = fields.Boolean("Customer Ratings", implied_group='project.group_project_rating')
|
|
group_project_recurring_tasks = fields.Boolean("Recurring Tasks", implied_group="project.group_project_recurring_tasks")
|
|
|
|
def set_values(self):
|
|
|
|
# Ensure that settings on existing projects match the above fields
|
|
projects = self.env["project.project"].search([])
|
|
features = (
|
|
# Pairs of associated (config_flag, project_flag)
|
|
("group_subtask_project", "allow_subtasks"),
|
|
("group_project_rating", "rating_active"),
|
|
("group_project_recurring_tasks", "allow_recurring_tasks"),
|
|
)
|
|
for (config_flag, project_flag) in features:
|
|
config_flag_global = "project." + config_flag
|
|
config_feature_enabled = self[config_flag]
|
|
if (self.user_has_groups(config_flag_global)
|
|
is not config_feature_enabled):
|
|
projects[project_flag] = config_feature_enabled
|
|
|
|
super(ResConfigSettings, self).set_values()
|