41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from odoo.tests.common import TransactionCase, tagged
|
|
|
|
|
|
@tagged("post_install", "-at_install")
|
|
class TestPlannerProject(TransactionCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
super().setUpClass()
|
|
cls.env = cls.env(user=cls.env.ref("base.user_admin"))
|
|
cls.env.user.groups_id |= cls.env.ref("planner.group_planner_manager")
|
|
|
|
def test_shift_has_project_and_hours_on_project(self):
|
|
project = self.env["project.project"].create({"name": "Planner link test"})
|
|
shift = self.env["planner.shift"].create(
|
|
{
|
|
"company_id": self.env.company.id,
|
|
"start_datetime": "2025-03-10 09:00:00",
|
|
"end_datetime": "2025-03-10 17:00:00",
|
|
"allocated_percentage": 100.0,
|
|
"project_id": project.id,
|
|
}
|
|
)
|
|
self.assertEqual(shift.project_id, project)
|
|
project.invalidate_recordset(["total_planner_hours"])
|
|
self.assertGreaterEqual(project.total_planner_hours, 0)
|
|
|
|
def test_template_name_includes_project(self):
|
|
project = self.env["project.project"].create({"name": "TemplProj"})
|
|
tmpl = self.env["planner.shift.template"].create(
|
|
{
|
|
"company_id": self.env.company.id,
|
|
"project_id": project.id,
|
|
"start_time": 9.0,
|
|
"end_time": 17.0,
|
|
"duration_days": 1,
|
|
}
|
|
)
|
|
self.assertIn("TemplProj", tmpl.name)
|