Skip to content

[19.0][FIX] maintenance_plan: post_init_hook crashes on Odoo 19 (removed equipment fields) - #580

Open
carlosffp wants to merge 2 commits into
OCA:19.0from
carlosffp:19.0-fix-maintenance_plan-hook
Open

[19.0][FIX] maintenance_plan: post_init_hook crashes on Odoo 19 (removed equipment fields)#580
carlosffp wants to merge 2 commits into
OCA:19.0from
carlosffp:19.0-fix-maintenance_plan-hook

Conversation

@carlosffp

Copy link
Copy Markdown

Installing maintenance_plan on Odoo 19 fails during post_init_hook with:

AttributeError: 'maintenance.equipment' object has no attribute 'next_action_date'

The migration hook references two maintenance.equipment fields that were removed in Odoo 19 core:

  • next_action_date — used to match "the" open preventive request by date
  • mtbf — used as the plan duration

Because it runs in post_init_hook, the whole install transaction rolls back and the module cannot be installed on any database that has equipments with expected_mtbf set.

Fix

Port the hook to Odoo 19:

  • Derive the plan interval from expected_mtbf (in days) and set interval_step = "day".
  • Drop the next_action_date matching / UserError branch (there is no next action date field to match against in 19) and the duration = mtbf line.
  • Batch the maintenance.plan creation.

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_mtbf set — install now completes and creates the expected plans.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants