-
-
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 18.0
- Loading branch information
1 parent
cc8a47f
commit 843af29
Showing
7 changed files
with
71 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 @@ | ||
from . import fleet_vehicle_cost |
65 changes: 65 additions & 0 deletions
65
fleet_vehicle_service_services/tests/fleet_vehicle_cost.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,65 @@ | ||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class TestFleetVehicleLogServiceServices(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
|
||
# Create test records for fleet.service.type | ||
cls.service_type_1 = cls.env["fleet.service.type"].create( | ||
{"name": "Oil Change"} | ||
) | ||
cls.service_type_2 = cls.env["fleet.service.type"].create( | ||
{"name": "Tire Replacement"} | ||
) | ||
|
||
# Create a test record for fleet.vehicle.log.services | ||
cls.log_service = cls.env["fleet.vehicle.log.services"].create( | ||
{ | ||
"name": "Service Log 1", | ||
"service_ids": [(6, 0, [cls.service_type_1.id, cls.service_type_2.id])], | ||
} | ||
) | ||
|
||
def test_service_ids_field(self): | ||
"""Test the service_ids Many2many field.""" | ||
# Check if the service_ids field contains the correct service types | ||
self.assertIn( | ||
self.service_type_1, | ||
self.log_service.service_ids, | ||
"Service Type 1 should be in the service_ids field.", | ||
) | ||
self.assertIn( | ||
self.service_type_2, | ||
self.log_service.service_ids, | ||
"Service Type 2 should be in the service_ids field.", | ||
) | ||
|
||
# Add another service type and ensure it's added | ||
new_service_type = self.env["fleet.service.type"].create( | ||
{"name": "Brake Check"} | ||
) | ||
self.log_service.write({"service_ids": [(4, new_service_type.id)]}) | ||
self.assertIn( | ||
new_service_type, | ||
self.log_service.service_ids, | ||
"New Service Type should be added to the service_ids field.", | ||
) | ||
|
||
def test_remove_service_type(self): | ||
"""Test removing a service type from the Many2many field.""" | ||
self.log_service.write({"service_ids": [(3, self.service_type_1.id)]}) | ||
self.assertNotIn( | ||
self.service_type_1, | ||
self.log_service.service_ids, | ||
"Service Type 1 should be removed from the service_ids field.", | ||
) | ||
|
||
def test_clear_all_service_types(self): | ||
"""Test clearing all service types.""" | ||
self.log_service.write({"service_ids": [(5, 0, 0)]}) # Clear all entries | ||
self.assertFalse( | ||
self.log_service.service_ids, | ||
"The service_ids field should be empty after clearing.", | ||
) |
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