diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/hr_timesheet/__init__.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/hr_timesheet/__init__.py')
| -rw-r--r-- | addons/hr_timesheet/__init__.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/addons/hr_timesheet/__init__.py b/addons/hr_timesheet/__init__.py new file mode 100644 index 00000000..0fa9235b --- /dev/null +++ b/addons/hr_timesheet/__init__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import controllers +from . import models +from . import report +from . import wizard + +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 + project_vals = [] + for company in env['res.company'].search([]): + company = company.with_company(company) + project_vals += [{ + 'name': _('Internal'), + 'allow_timesheets': True, + 'company_id': company.id, + 'task_ids': [(0, 0, { + 'name': name, + 'company_id': company.id, + }) for name in [_('Training'), _('Meeting')]] + }] + project_ids = env['project.project'].create(project_vals) + + env['account.analytic.line'].create([{ + 'name': _("Analysis"), + 'user_id': admin.id, + 'date': fields.datetime.today(), + 'unit_amount': 0, + 'project_id': task.project_id.id, + 'task_id': task.id, + } for task in project_ids.task_ids.filtered(lambda t: t.company_id in admin.employee_ids.company_id)]) |
