From e6f640c72c6495adc0c132576eccc418f630f958 Mon Sep 17 00:00:00 2001 From: kaynnan Date: Mon, 10 Jul 2023 09:03:37 -0300 Subject: [PATCH] [MIG] fieldservice_fleet: Migration to 15.0 --- fieldservice_fleet/__manifest__.py | 2 +- .../tests/test_fsm_fleet_wizard.py | 26 ++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/fieldservice_fleet/__manifest__.py b/fieldservice_fleet/__manifest__.py index 90c5cf44a3..c70e00b868 100644 --- a/fieldservice_fleet/__manifest__.py +++ b/fieldservice_fleet/__manifest__.py @@ -5,7 +5,7 @@ { "name": "Field Service Fleet", "summary": "Link Field Service vehicles with Odoo Fleet", - "version": "14.0.1.0.0", + "version": "15.0.1.0.0", "category": "Field Service", "author": "Brian McMaster, " "Open Source Integrators, " diff --git a/fieldservice_fleet/tests/test_fsm_fleet_wizard.py b/fieldservice_fleet/tests/test_fsm_fleet_wizard.py index 04bba92a22..ca7f5e83ca 100644 --- a/fieldservice_fleet/tests/test_fsm_fleet_wizard.py +++ b/fieldservice_fleet/tests/test_fsm_fleet_wizard.py @@ -24,6 +24,18 @@ def test_convert_vehicle(self): [("fleet_vehicle_id", "=", self.fleet_vehicle_1.id)] ) + # Create a driver partner without an associated fsm.person record + driver_partner = self.env["res.partner"].create( + { + "name": "Driver Partner", + } + ) + + # Retrieve the fsm_worker record for the driver partner + fsm_worker = self.env["fsm.person"].search( + [("partner_id", "=", driver_partner.id)] + ) + self.assertEqual( len(fsm_vehicle), 1, @@ -47,6 +59,18 @@ def test_convert_vehicle(self): """FSM Fleet Wizard: FSM vehicle driver is not same as the Fleet vehicle driver""", ) + self.assertTrue( + self.fleet_vehicle_1.driver_id and self.fleet_vehicle_1.is_fsm_vehicle, + "Driver ID and is_fsm_vehicle condition is not True", + ) + + # Set the driver_id of the fleet vehicle to the driver partner + self.fleet_vehicle_1.driver_id = driver_partner.id + + # Assert that fsm_worker is not found + self.assertFalse( + fsm_worker, "FSM worker found for driver partner, but it should not exist" + ) # Attempt to convert the Fleet vehicle again, but expect UserError # because we already converted it @@ -97,4 +121,4 @@ def test_fsm_vehicle(self): "active_ids": [self.fleet_vehicle_3.id], "active_id": self.fleet_vehicle_3.id, } - self.Wizard.with_context(self.context).action_convert() + self.Wizard.with_context(**self.context).action_convert()