[19.0][FIX] maintenance_plan: post_init_hook crashes on Odoo 19 (removed equipment fields) - #580
Open
carlosffp wants to merge 2 commits into
Open
[19.0][FIX] maintenance_plan: post_init_hook crashes on Odoo 19 (removed equipment fields)#580carlosffp wants to merge 2 commits into
carlosffp wants to merge 2 commits into
Conversation
…fields Odoo 19 removed maintenance.equipment.next_action_date and .mtbf; the post_init_hook relied on both and raised AttributeError on install, rolling back the whole transaction on any DB with equipments that have expected_mtbf set. Derive the plan interval from expected_mtbf (in days, interval_step=day), drop the next_action_date matching / UserError branch and the mtbf-based duration, and batch the maintenance.plan creation.
Cover the Odoo 19 post_init_hook: a maintenance.plan (kind 'Install') is created for each equipment with an expected MTBF, using the MTBF as the interval (in days), and equipment without an expected MTBF gets no plan from the hook.
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.
Installing
maintenance_planon Odoo 19 fails duringpost_init_hookwith:The migration hook references two
maintenance.equipmentfields that were removed in Odoo 19 core:next_action_date— used to match "the" open preventive request by datemtbf— used as the plandurationBecause it runs in
post_init_hook, the whole install transaction rolls back and the module cannot be installed on any database that has equipments withexpected_mtbfset.Fix
Port the hook to Odoo 19:
intervalfromexpected_mtbf(in days) and setinterval_step = "day".next_action_datematching /UserErrorbranch (there is no next action date field to match against in 19) and theduration = mtbfline.maintenance.plancreation.The end result is equivalent: one
maintenance.plan(kind "Install") per equipment that had an expected MTBF, using the MTBF as the interval.Tested by installing the module on an Odoo 19 database (ASSA) with equipments that have
expected_mtbfset — install now completes and creates the expected plans.