summaryrefslogtreecommitdiff
path: root/addons/project_timesheet_holidays/__init__.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/project_timesheet_holidays/__init__.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/project_timesheet_holidays/__init__.py')
-rw-r--r--addons/project_timesheet_holidays/__init__.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/addons/project_timesheet_holidays/__init__.py b/addons/project_timesheet_holidays/__init__.py
new file mode 100644
index 00000000..388eef6f
--- /dev/null
+++ b/addons/project_timesheet_holidays/__init__.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import models
+
+
+def post_init(cr, registry):
+ """ Set the timesheet project and task on existing leave type. Do it in post_init to
+ be sure the internal project/task of res.company are set. (Since timesheet_generate field
+ is true by default, those 2 fields are required on the leave type).
+ """
+ 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.leave_timesheet_project_id.id,
+ 'timesheet_task_id': company.leave_timesheet_task_id.id,
+ })