Maintainers
This module is maintained by the OCA.
- - - +OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
diff --git a/maintenance_project/tests/test_maintenance_project.py b/maintenance_project/tests/test_maintenance_project.py index 6ed884f0e..82ff17de4 100644 --- a/maintenance_project/tests/test_maintenance_project.py +++ b/maintenance_project/tests/test_maintenance_project.py @@ -7,9 +7,8 @@ class TestMaintenanceProject(test_common.TransactionCase): @classmethod def setUpClass(cls): - super(TestMaintenanceProject, cls).setUpClass() + super().setUpClass() - cls.cron = cls.env.ref("maintenance.maintenance_requests_cron") cls.project1 = cls.env["project.project"].create({"name": "My project"}) cls.project_demo1 = cls.env.ref("maintenance_project.project_project_1") @@ -20,8 +19,6 @@ def setUpClass(cls): "maintenance_team_id": cls.env.ref( "maintenance.equipment_team_metrology" ).id, - "period": 30, - "maintenance_duration": 1.0, } ) cls.equipment2 = cls.env["maintenance.equipment"].create( @@ -69,15 +66,34 @@ def test_request_onchange_equipment(self): self.assertFalse(req2.project_id) def test_generate_requests(self): - self.cron.method_direct_trigger() - - generated_requests = self.env["maintenance.request"].search( - [("project_id", "!=", False)] + req_name = "My new recurring test request" + req = self.env["maintenance.request"].create( + { + "name": req_name, + "maintenance_type": "preventive", + "duration": 1.0, + "recurring_maintenance": True, + "repeat_interval": 1, + "repeat_unit": "month", + "repeat_type": "forever", + } ) - for req in generated_requests: - self.assertEqual(req.project_id, req.equipment_id.project_id) - self.assertEqual(req.task_id, req.equipment_id.preventive_default_task_id) - self.assertEqual(req.project_id.maintenance_request_count, 1) + req.equipment_id = self.equipment1 + req.onchange_equipment_id() + req.description = "Request done!" + + request_obj = self.env["maintenance.request"] + domain = [ + ("name", "=", req_name), + ("equipment_id", "=", self.equipment1.id), + ("project_id", "=", self.equipment1.project_id.id), + ] + my_requests = request_obj.search(domain) + self.assertEqual(len(my_requests), 1) + + req.stage_id = self.env.ref("maintenance.stage_3") + my_requests = request_obj.search(domain) + self.assertEqual(len(my_requests), 2) def test_action_views(self): act1 = self.project1.action_view_equipment_ids() diff --git a/maintenance_project/views/maintenance_equipment_views.xml b/maintenance_project/views/maintenance_equipment_views.xml index 554be3b94..28e14b157 100644 --- a/maintenance_project/views/maintenance_equipment_views.xml +++ b/maintenance_project/views/maintenance_equipment_views.xml @@ -27,7 +27,7 @@