[FIX] hr_timesheet: uninstall project's 'timesheet' config

Steps :
Go to project > settings.
Check 'timesheet' config and save.
Uncheck it back and save.

Issue :
See errors in the logs, due to on delete restrict.

Cause :
Record 'hr_timesheet.internal_project_default_stage' from data
is deleted when hr_timesheet is uninstalled.
Yet some project task records still use it, so we can't delete it.

Fix :
Delete the corresponding ir.model.data to keep the stage,
but unlink it from the 'hr_timesheet.internal_project_default_stage' ref.

task-2998416

closes odoo/odoo#106354

X-original-commit: c9e49358111521c042dd793f80ff99895d0fd179
Related: odoo/enterprise#34317
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
This commit is contained in:
Audric Onockx (auon)
2022-11-23 19:59:59 +01:00
parent e9bf6d732a
commit 4fe0ce8460
+2
View File
@@ -44,3 +44,5 @@ def _uninstall_hook(cr, registry):
project_ids = env['res.company'].search([('internal_project_id', '!=', False)]).mapped('internal_project_id')
if project_ids:
project_ids.write({'active': False})
env['ir.model.data'].search([('name', 'ilike', 'internal_project_default_stage')]).unlink()