Skip to content

Commit

Permalink
[MIG] fleet_vehicle_service_services: Migration to 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Jan 9, 2025
1 parent cc8a47f commit 843af29
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 2 deletions.
1 change: 1 addition & 0 deletions fleet_vehicle_service_services/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Contributors
------------

- Miquel Raïch <miquel.raich@forgeflow.com>
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion fleet_vehicle_service_services/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Fleet Vehicle Service Services",
"summary": "Add subservices in Services.",
"version": "16.0.1.0.0",
"version": "18.0.1.0.0",
"category": "Human Resources/Fleet",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/fleet",
Expand Down
1 change: 1 addition & 0 deletions fleet_vehicle_service_services/readme/CONTRIBUTORS.md
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)
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ <h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>Miquel Raïch &lt;<a class="reference external" href="mailto:miquel.raich&#64;forgeflow.com">miquel.raich&#64;forgeflow.com</a>&gt;</li>
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a></li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
1 change: 1 addition & 0 deletions fleet_vehicle_service_services/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import fleet_vehicle_cost
65 changes: 65 additions & 0 deletions fleet_vehicle_service_services/tests/fleet_vehicle_cost.py
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.",
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<field name="model">fleet.vehicle.log.services</field>
<field name="inherit_id" ref="fleet.fleet_vehicle_log_services_view_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='notes']/.." position="before">
<xpath expr="//sheet//separator" position="before">
<group string="Included Services">
<field name="service_ids" widget="many2many_tags" nolabel="1" />
</group>
Expand Down

0 comments on commit 843af29

Please sign in to comment.