Skip to content

Commit

Permalink
[FIX] project_timesheet_holidays: can't set timesheet_task_id when
Browse files Browse the repository at this point in the history
install module

* PROPBLEM: since odoo#173719 we have moved
from init to post_init which will make timesheet_task_id of
hr.leave.type can't set value because in post_init
company.leave_timesheet_task_id will be set

* SOLUTION: fill it in post_init instead

closes odoo#177585

X-original-commit: de3c30e
Signed-off-by: Xavier Bol (xbo) <[email protected]>
  • Loading branch information
duong77476-viindoo committed Aug 26, 2024
1 parent a4fd26b commit 7635323
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions addons/project_timesheet_holidays/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ def post_init(cr, registry):
from odoo import api, SUPERUSER_ID

env = api.Environment(cr, SUPERUSER_ID, {})
for hr_leave_type in env['hr.leave.type'].search([('timesheet_generate', '=', True), ('timesheet_project_id', '=', False)]):
company = hr_leave_type.company_id or env.company
hr_leave_type.write({
'timesheet_project_id': company.internal_project_id.id,
'timesheet_task_id': company.leave_timesheet_task_id.id,
})

type_ids_ref = env.ref('hr_timesheet.internal_project_default_stage', raise_if_not_found=False)
type_ids = [(4, type_ids_ref.id)] if type_ids_ref else []
Expand Down Expand Up @@ -54,3 +48,10 @@ def post_init(cr, registry):
company.write({
'leave_timesheet_task_id': task.id,
})

for hr_leave_type in env['hr.leave.type'].search(['|', ('timesheet_project_id', '=', False), ('timesheet_task_id', '=', False)]):
company = hr_leave_type.company_id or env.company
hr_leave_type.write({
'timesheet_project_id': company.internal_project_id.id,
'timesheet_task_id': company.leave_timesheet_task_id.id,
})

0 comments on commit 7635323

Please sign in to comment.