Skip to content
Open
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
4 changes: 2 additions & 2 deletions docsource/modules180-190.rst
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ Module coverage 18.0 -> 19.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| mail_plugin | |No DB layout changes. |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| maintenance | | |
| maintenance |Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| marketing_card | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down Expand Up @@ -1098,7 +1098,7 @@ Module coverage 18.0 -> 19.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| stock_landed_costs | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| |new| stock_maintenance | | |
| |new| stock_maintenance |Nothing to do | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| stock_picking_batch | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
17 changes: 17 additions & 0 deletions openupgrade_scripts/scripts/maintenance/19.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2026 Tecnativa - Carlos Lopez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env, "maintenance", "19.0.1.0/noupdate_changes.xml")
openupgrade.delete_record_translations(
env.cr,
"maintenance",
["mail_act_maintenance_request"],
["summary"],
)
model_id = env["ir.model"]._get_id("maintenance.equipment.category")
env["mail.alias"].search([("alias_parent_model_id", "=", model_id)]).unlink()
49 changes: 49 additions & 0 deletions openupgrade_scripts/scripts/maintenance/19.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2026 Tecnativa - Carlos Lopez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade

_added_fields = [
(
"schedule_end",
"maintenance.request",
"maintenance_request",
"datetime",
None,
"maintenance",
)
]


def fill_maintenance_request_schedule_end(env):
"""
Fill the schedule_end field in maintenance.request records
based on schedule_date and duration.
If duration is not set, default to 1 hour.
"""
openupgrade.logged_query(
env.cr,
"""
UPDATE maintenance_request mr
SET schedule_end = schedule_date + INTERVAL '1 hour' * (
CASE
WHEN mr.duration = 0 THEN 1
ELSE COALESCE(mr.duration, 1)
END
)
WHERE mr.schedule_date IS NOT NULL
""",
)
Comment thread
carlos-lopez-tecnativa marked this conversation as resolved.


@openupgrade.migrate()
def migrate(env, version):
openupgrade.add_fields(env, _added_fields)
fill_maintenance_request_schedule_end(env)
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE maintenance_equipment_category
DROP CONSTRAINT IF EXISTS maintenance_equipment_category_alias_id_fkey;
""",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---Models in module 'maintenance'---
---Fields in module 'maintenance'---
maintenance / maintenance.equipment / location (char) : DEL
# NOTHING TO DO: Odoo converts this field from char to many2one in the new stock_maintenance module.
# However, before this change, the location field was only informational, so we did not recreate it as a stock.location records.
# see https://github.com/odoo/odoo/pull/186032

maintenance / maintenance.equipment / match_serial (boolean) : module is now 'stock_maintenance' ('maintenance')
# NOTHING TO DO: It was simply moved to the stock_maintenance module.

maintenance / maintenance.equipment.category / alias_id (many2one) : DEL relation: mail.alias, required
maintenance / maintenance.equipment.category / _inherits : DEL _inherits: {'mail.alias': 'alias_id'}, stored: False
maintenance / maintenance.equipment.category / message_follower_ids (one2many): DEL relation: mail.followers
maintenance / maintenance.equipment.category / message_ids (one2many) : DEL relation: mail.message
Comment thread
carlos-lopez-tecnativa marked this conversation as resolved.
# DONE: post-migration, delete the mail.alias records related to maintenance.equipment.category

maintenance / maintenance.team / _inherits : NEW _inherits: {'mail.alias': 'alias_id'}, stored: False
maintenance / maintenance.team / alias_id (many2one) : NEW relation: mail.alias, required
maintenance / maintenance.team / message_follower_ids (one2many): NEW relation: mail.followers
maintenance / maintenance.team / message_ids (one2many) : NEW relation: mail.message
# NOTHING TO DO: There are no direct relationships that allow translating data from maintenance.equipment.category to maintenance.team.
# See https://github.com/odoo/odoo/pull/196181

maintenance / maintenance.request / duration (float) : now a function
# NOTHING TO DO: The field is now computed, but the underlying logic remains the same. The existing data is preserved.

maintenance / maintenance.request / schedule_end (datetime) : NEW hasdefault: compute
# DONE: pre-migration precreated and populated based on schedule_date and duration when duration was set.
# Otherwise, one hour was added to schedule_date, matching Odoo's field computation logic.

---XML records in module 'maintenance'---
NEW res.groups.privilege: maintenance.res_groups_privilege_maintenance
# NOTHING TO DO: New feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---Models in module 'stock_maintenance'---
---Fields in module 'stock_maintenance'---
stock_maintenance / maintenance.equipment / location_id (many2one) : NEW relation: stock.location
# NOTHING TO DO: New feature

stock_maintenance / maintenance.equipment / match_serial (boolean) : previously in module maintenance
# NOTHING TO DO: It was simply moved to the maintenance module.

---XML records in module 'stock_maintenance'---
NEW ir.ui.view: stock_maintenance.maintenance_stock_equipment_view_form
NEW ir.ui.view: stock_maintenance.stock_location_form_maintenance_equipments
# NOTHING TO DO: Handled by ORM
Loading