Purpose ======= In Project, the configuration has to be done twice: in the settings of the app and on each project. During the onboarding, the user won't understand that a feature has to be enabled at both places and will think that the system just doesn't work. If the user enabled a feature, he most likely intends on using it for most of his projects. Therefore, having to do a double configuration for each new project is annoying. By the way, sub-tasks is the only global feature (it can't be enabled or disabled by project), so we are breaking it down by project to remain consistent with the rest. Specification ============= 1/ Enable subtasks per project Before this commit, sub-tasks were a global feature (i.e. once enabled they were enabled for all projects). This commit gives the ability to enable/disable sub-tasks per project. 2/ Make project_id on planning required 3/ Change default rating status on new projects 4/ Default value for allow_subtasks 5/ Enable timesheets on existing projects 6/ Hide Total Hours if subtasks are disabled 7/ Create project in the company context. Otherwise some records generation could use a default company which is not the company for which we want to create a project. 8/ Default value for allow_forecast, is_fsm 9/ Change reference to timesheet product 10/ Fix tracback on industry_fsm_report. Before this commit, there was a traceback when enabling "Worksheets" (industry_fsm_report) after "Time and Material" (industry_fsm_sale). 11/ Convert some onchange method into computed editable stored fields closes odoo/odoo#41218 Taskid: 2146474 Related: odoo/enterprise#6998 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com> Co-authored-by: Yannick Tivisse <yti@odoo.com>
28 lines
1.1 KiB
Python
28 lines
1.1 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("Use Rating on Project", implied_group='project.group_project_rating')
|
|
|
|
def _get_subtasks_projects_domain(self):
|
|
return []
|
|
|
|
def execute(self):
|
|
res = super(ResConfigSettings, self).execute()
|
|
if self.group_project_rating:
|
|
# Change the rating status on existing projects from 'no' to 'stage'
|
|
self.env['project.project'].search([('rating_status', '=', 'no')]).write({
|
|
'rating_status': 'stage'})
|
|
if self.group_subtask_project:
|
|
domain = self._get_subtasks_projects_domain()
|
|
self.env['project.project'].search(domain).write({'allow_subtasks': True})
|
|
return res
|