Skip to content

[6788][ADD] maintenance_equipment_usability - #10

Open
smorita7749 wants to merge 4 commits into
18.0from
6788-add-maintenance_equipment_usability
Open

[6788][ADD] maintenance_equipment_usability#10
smorita7749 wants to merge 4 commits into
18.0from
6788-add-maintenance_equipment_usability

Conversation

@smorita7749

Copy link
Copy Markdown
Contributor

Add maintenance_equipment_usability.

Computes equipment usability from the equipment status, the latest completed maintenance request result, and a configurable usability grace period.

  • Equipment status (Preparing / Operating / Idle / Retired / Scrapped): only equipment in the Operating status can be usable.
  • Maintenance result (Passed / Failed) on maintenance requests, with follow-up request creation for failed results.
  • Usability (Unknown / Usable / Unusable) computed on the equipment (not stored; searchable), with badges and filters on the equipment list/kanban/search.
  • Usability grace period configured per company in Settings > Maintenance (default 12 months).

@smorita7749
smorita7749 force-pushed the 6788-add-maintenance_equipment_usability branch from 7023b5d to 6fd5595 Compare July 10, 2026 01:56
@smorita7749
smorita7749 force-pushed the 6788-add-maintenance_equipment_usability branch 3 times, most recently from 600ccb3 to ae51bb1 Compare July 22, 2026 13:33
def _compute_latest_maintenance_result(self):
requests = (
self.env["maintenance.request"]
.sudo()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why sudo() is needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the record rule level, general users can only see requests they created, follow, or are assigned to as technician.
Sudo() is used to avoid _compute_latest_maintenance_result producing an unstable result depending on who triggers it.

Comment on lines +13 to +16
help="Number of months the equipment stays usable after its latest "
"passed maintenance result. Validity extends to the end of the target "
"month (e.g. passed on 15 June with 13 months stays usable until 31 "
"July of the following year).",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add help in here since it is not useful because settings view help will handle that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Comment on lines +14 to +17
help="Number of months the equipment stays usable after its latest "
"passed maintenance result. Validity extends to the end of the target "
"month (e.g. passed on 15 June with 13 months stays usable until 31 "
"July of the following year).",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

"latest_maintenance_result_date",
)
def _compute_usability(self):
grace_months = self.env.company.usability_grace_period_months

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use equipment.company_id.usability_grace_period_months?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to user company_id.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants