Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] add seq widget to templates #158

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ repos:
- --color
- --fix
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
# exclude autogenerated files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class FleetVehicleInspectionLine(models.Model):
copy=False,
)
result_description = fields.Char()
sequence = fields.Integer(default=10)
state = fields.Selection(
related="inspection_id.state",
readonly=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
context="{'default_inspection_id': active_id}"
>
<tree>
<field name="sequence" widget="handle" />
<field name="state" invisible="1" />
<field name="inspection_item_id" />
<field name="inspection_item_instruction" />
Expand Down
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)
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
Loading