diff --git a/fleet_vehicle_inspection_template/tests/test_fleet_vehicle_inspection_template.py b/fleet_vehicle_inspection_template/tests/test_fleet_vehicle_inspection_template.py index b2f3b16d..39d9cb4d 100644 --- a/fleet_vehicle_inspection_template/tests/test_fleet_vehicle_inspection_template.py +++ b/fleet_vehicle_inspection_template/tests/test_fleet_vehicle_inspection_template.py @@ -13,9 +13,9 @@ def setUpClass(cls): cls.inspection_template = cls.env["fleet.vehicle.inspection.template"] cls.vehicle = cls.env.ref("fleet.vehicle_5").id - cls.item_01 = cls.inspection_item.create({"name": "Lights"}) + cls.item_01 = cls.inspection_item.create({"name": "Lights", "sequence": 1}) - cls.item_02 = cls.inspection_item.create({"name": "Mirrors"}) + cls.item_02 = cls.inspection_item.create({"name": "Mirrors", "sequence": 2}) cls.inspection_template = cls.inspection_template.create( { @@ -24,7 +24,10 @@ def setUpClass(cls): ( 0, 0, - {"inspection_template_item_id": cls.item_01.id}, + { + "inspection_template_item_id": cls.item_01.id, + "sequence": 5, # Different sequence in the template line + }, ), ( 0, @@ -43,7 +46,23 @@ def setUpClass(cls): ) def test_fleet_vehicle_inspection(self): - self.inspection._onchange_inspection_template_id() + + # Existing assertions self.assertEqual(self.inspection.name, self.inspection_template.name) self.assertTrue(self.inspection.inspection_line_ids) + + # New assertions for sequence + self.assertEqual(len(self.inspection.inspection_line_ids), 2) + + # Check if the sequence is correctly copied from the template line + line_1 = self.inspection.inspection_line_ids.filtered( + lambda linei: linei.inspection_item_id == self.item_01 + ) + self.assertEqual(line_1.sequence, 5) + + # Check if the sequence defaults to the item's sequence if not set in the template line + line_2 = self.inspection.inspection_line_ids.filtered( + lambda linei: linei.inspection_item_id == self.item_02 + ) + self.assertEqual(line_2.sequence, self.item_02.sequence)