From 8dd0edae898a532dbe7e4f18c9118b9b68e57900 Mon Sep 17 00:00:00 2001 From: Dominik Rubo Date: Fri, 21 Aug 2020 09:46:28 +0000 Subject: [IMP] project: enable config-selected features in projects 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#58692 Related: odoo/enterprise#13641 Signed-off-by: Yannick Tivisse (yti) Co-authored-by: Kevin Baptiste <50135801+kba-odoo@users.noreply.github.com> --- addons/hr_timesheet/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'addons/hr_timesheet') diff --git a/addons/hr_timesheet/__init__.py b/addons/hr_timesheet/__init__.py index 6aab6c417a5..0fa9235b104 100644 --- a/addons/hr_timesheet/__init__.py +++ b/addons/hr_timesheet/__init__.py @@ -11,6 +11,11 @@ from odoo import api, fields, SUPERUSER_ID, _ def create_internal_project(cr, registry): env = api.Environment(cr, SUPERUSER_ID, {}) + + # allow_timesheets is set by default, but erased for existing projects at + # installation, as there is no analytic account for them. + env['project.project'].search([]).write({'allow_timesheets': True}) + admin = env.ref('base.user_admin', raise_if_not_found=False) if not admin: return -- cgit v1.2.3