Files
odoo_source/addons/hr_timesheet/__init__.py
T
Francois (fge) 568fe91341 [FIX] project: fix various bugs
Restore Project Kanban view for mobile.
Added a name for the default stage of the tasks in the Internal project
Removal of redundancy for the creation of the Internal project and its tasks
Fix task_reccurrence for the type 'after'. (too much task created or bad task created)

Task-2326258

closes odoo/odoo#64607

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2021-01-15 12:20:54 +00:00

31 lines
1.0 KiB
Python

# -*- 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_ids = env['res.company'].search([])._create_internal_project_task()
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)])