From 9ef67c1c7d6e36e9ceae0413b7273758d66a2ced Mon Sep 17 00:00:00 2001 From: RPSJR Date: Sun, 27 Oct 2024 20:15:27 -0300 Subject: [PATCH] [16.0][IMP] ADD seq widget to inspect template --- .../models/fleet_vehicle_inspection.py | 7 ++++++- .../models/fleet_vehicle_inspection_template_line.py | 2 ++ fleet_vehicle_inspection_template/test-requirements.txt | 0 .../views/fleet_vehicle_inspection_template.xml | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 fleet_vehicle_inspection_template/test-requirements.txt diff --git a/fleet_vehicle_inspection_template/models/fleet_vehicle_inspection.py b/fleet_vehicle_inspection_template/models/fleet_vehicle_inspection.py index d49e6e97..5f075dbb 100644 --- a/fleet_vehicle_inspection_template/models/fleet_vehicle_inspection.py +++ b/fleet_vehicle_inspection_template/models/fleet_vehicle_inspection.py @@ -15,6 +15,7 @@ class FleetVehicleInspection(models.Model): def _compute_line_data_for_template_change(self, line): return { "inspection_item_id": line.inspection_template_item_id.id, + "sequence": line.sequence, "state": "draft", } @@ -25,7 +26,11 @@ def _onchange_inspection_template_id(self): self.note = self.inspection_template_id.note inspection_lines = [(5, 0, 0)] - for line in self.inspection_template_id.inspection_template_line_ids: + # Sort the lines by sequence before appending + for line in sorted( + self.inspection_template_id.inspection_template_line_ids, + key=lambda linei: linei.sequence, + ): data = self._compute_line_data_for_template_change(line) inspection_lines.append((0, 0, data)) diff --git a/fleet_vehicle_inspection_template/models/fleet_vehicle_inspection_template_line.py b/fleet_vehicle_inspection_template/models/fleet_vehicle_inspection_template_line.py index 9e79a76d..79d42311 100644 --- a/fleet_vehicle_inspection_template/models/fleet_vehicle_inspection_template_line.py +++ b/fleet_vehicle_inspection_template/models/fleet_vehicle_inspection_template_line.py @@ -24,3 +24,5 @@ class FleetVehicleInspectionTemplateLine(models.Model): required=True, copy=True, ) + + sequence = fields.Integer(default=10) diff --git a/fleet_vehicle_inspection_template/test-requirements.txt b/fleet_vehicle_inspection_template/test-requirements.txt new file mode 100644 index 00000000..e69de29b diff --git a/fleet_vehicle_inspection_template/views/fleet_vehicle_inspection_template.xml b/fleet_vehicle_inspection_template/views/fleet_vehicle_inspection_template.xml index 90667738..810ea7a3 100644 --- a/fleet_vehicle_inspection_template/views/fleet_vehicle_inspection_template.xml +++ b/fleet_vehicle_inspection_template/views/fleet_vehicle_inspection_template.xml @@ -27,6 +27,7 @@ > +