Skip to content

Commit

Permalink
[MIG] fleet_vehicle_service_services: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Dec 31, 2024
1 parent 1e8cda2 commit 2e6aa5b
Show file tree
Hide file tree
Showing 7 changed files with 91 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": "17.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
4 changes: 4 additions & 0 deletions fleet_vehicle_service_services/tests/__init__.py
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
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.",
)
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 2e6aa5b

Please sign in to comment.