-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] fleet_vehicle_service_services: Migration to 17.0
- Loading branch information
1 parent
1e8cda2
commit 2e6aa5b
Showing
7 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
- Miquel Raïch \<<miquel.raich@forgeflow.com>\> | ||
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2022 ForgeFlow S.L. <https://www.forgeflow.com> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_vehicle_service_services |
82 changes: 82 additions & 0 deletions
82
fleet_vehicle_service_services/tests/test_vehicle_service_services.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Copyright 2022 ForgeFlow S.L. <https://www.forgeflow.com> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestFleetVehicleLogServices(TransactionCase): | ||
def setUp(self): | ||
"""Set up initial data for the test cases.""" | ||
super().setUp() | ||
|
||
vehicle_model = self.env["fleet.vehicle.model"].create( | ||
{ | ||
"name": "Model Name", | ||
"brand_id": 1, | ||
} | ||
) | ||
|
||
self.vehicle = self.env["fleet.vehicle"].create( | ||
{ | ||
"model_id": vehicle_model.id, | ||
} | ||
) | ||
|
||
self.service_type_1 = self.env["fleet.service.type"].create( | ||
{ | ||
"name": "Oil Change", | ||
"category": "service", | ||
} | ||
) | ||
self.service_type_2 = self.env["fleet.service.type"].create( | ||
{ | ||
"name": "Tire Replacement", | ||
"category": "service", | ||
} | ||
) | ||
|
||
# Create a fleet vehicle log services record | ||
self.vehicle_log_service = self.env["fleet.vehicle.log.services"].create( | ||
{ | ||
"service_type_id": self.service_type_1.id, | ||
"odometer": 15000, | ||
"vehicle_id": self.vehicle.id, # Link log to the vehicle | ||
} | ||
) | ||
|
||
def test_many2many_service_ids(self): | ||
"""Test if the Many2many relation works correctly for service_ids.""" | ||
|
||
# Assign service types to the vehicle log service | ||
self.vehicle_log_service.write( | ||
{ | ||
"service_ids": [ | ||
(6, 0, [self.service_type_1.id, self.service_type_2.id]) | ||
], | ||
} | ||
) | ||
|
||
# Check if the service_ids field is correctly updated | ||
self.assertEqual( | ||
len(self.vehicle_log_service.service_ids), | ||
2, | ||
"The vehicle log service should have 2 services.", | ||
) | ||
self.assertTrue( | ||
self.service_type_1 in self.vehicle_log_service.service_ids, | ||
"The 'Oil Change' service should be included.", | ||
) | ||
self.assertTrue( | ||
self.service_type_2 in self.vehicle_log_service.service_ids, | ||
"The 'Tire Replacement' service should be included.", | ||
) | ||
|
||
def test_empty_service_ids(self): | ||
"""Test if the Many2many relation is empty initially.""" | ||
|
||
# Ensure no services are included in the vehicle log service initially | ||
self.assertEqual( | ||
len(self.vehicle_log_service.service_ids), | ||
0, | ||
"The vehicle log service should have no services initially.", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters