Skip to content

Commit

Permalink
[16.0][IMP] ADD seq widget to inspect template
Browse files Browse the repository at this point in the history
  • Loading branch information
RPSJR committed Oct 27, 2024
1 parent c9cb05b commit 9ef67c1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand All @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ class FleetVehicleInspectionTemplateLine(models.Model):
required=True,
copy=True,
)

sequence = fields.Integer(default=10)
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
>
<field name="inspection_template_line_ids">
<tree editable="bottom">
<field name="sequence" widget="handle" />
<field
name="inspection_template_item_id"
string="Inspection Template Line"
Expand Down

0 comments on commit 9ef67c1

Please sign in to comment.