diff --git a/maintenance_project/__manifest__.py b/maintenance_project/__manifest__.py index 3ac777887..93e37c578 100644 --- a/maintenance_project/__manifest__.py +++ b/maintenance_project/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Maintenance Projects", "summary": "Adds projects to maintenance equipments and requests", - "version": "16.0.1.0.0", + "version": "17.0.1.0.0", "author": "Odoo Community Association (OCA), Solvos", "license": "AGPL-3", "category": "Maintenance", @@ -16,6 +16,6 @@ "views/project_project_views.xml", "report/maintenance_request_report.xml", ], - "demo": ["data/demo_maintenance_project.xml"], + "demo": ["demo/demo_maintenance_project.xml"], "installable": True, } diff --git a/maintenance_project/data/demo_maintenance_project.xml b/maintenance_project/demo/demo_maintenance_project.xml similarity index 96% rename from maintenance_project/data/demo_maintenance_project.xml rename to maintenance_project/demo/demo_maintenance_project.xml index d41b6febd..df3893b7c 100644 --- a/maintenance_project/data/demo_maintenance_project.xml +++ b/maintenance_project/demo/demo_maintenance_project.xml @@ -38,8 +38,6 @@ MODEL2 - - Contributors

Maintainers

This module is maintained by the OCA.

- -Odoo Community Association - +Odoo Community Association

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 @@
- Project: + Project:
@@ -37,16 +37,13 @@ - + - +
- Project: + Project: