[6788][ADD] maintenance_equipment_usability - #10
Open
smorita7749 wants to merge 4 commits into
Open
Conversation
smorita7749
force-pushed
the
6788-add-maintenance_equipment_usability
branch
from
July 10, 2026 01:56
7023b5d to
6fd5595
Compare
smorita7749
force-pushed
the
6788-add-maintenance_equipment_usability
branch
3 times, most recently
from
July 22, 2026 13:33
600ccb3 to
ae51bb1
Compare
| def _compute_latest_maintenance_result(self): | ||
| requests = ( | ||
| self.env["maintenance.request"] | ||
| .sudo() |
Contributor
There was a problem hiding this comment.
why sudo() is needed?
Contributor
Author
There was a problem hiding this comment.
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).", |
Contributor
There was a problem hiding this comment.
Don't add help in here since it is not useful because settings view help will handle that.
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).", |
| "latest_maintenance_result_date", | ||
| ) | ||
| def _compute_usability(self): | ||
| grace_months = self.env.company.usability_grace_period_months |
Contributor
There was a problem hiding this comment.
Why don't you use equipment.company_id.usability_grace_period_months?
Contributor
Author
There was a problem hiding this comment.
I changed it to user company_id.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
maintenance_equipment_usability.Computes equipment usability from the equipment status, the latest completed maintenance request result, and a configurable usability grace period.