Skip to content

Commit 5876b00

Browse files
authored
Merge pull request #1278 from ForgeFlow/18.0-fix-contract-migration
[18.0][FIX] contract: migration scripts
2 parents e80d3c7 + 163bf3f commit 5876b00

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com)
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3+
from openupgradelib import openupgrade
4+
5+
6+
@openupgrade.migrate()
7+
def migrate(env, version):
8+
env.cr.execute(
9+
"""
10+
SELECT name
11+
FROM ir_module_module
12+
WHERE state='uninstalled' AND name IN (
13+
'contract_line_successor', 'contract_termination');"""
14+
)
15+
uninstalled_modules = [x[0] for x in env.cr.fetchall()]
16+
no_update_xml_ids = {
17+
"contract_line_successor": [
18+
"contract_line_cron_for_renew",
19+
],
20+
"contract_termination": [],
21+
}
22+
xmlids_spec = []
23+
for new_module, moved_xml_ids in no_update_xml_ids.items():
24+
if new_module in uninstalled_modules:
25+
xmlids_spec.extend([f"{new_module}.{xml_id}" for xml_id in moved_xml_ids])
26+
if xmlids_spec:
27+
openupgrade.delete_records_safely_by_xml_id(env, xmlids_spec)

contract/migrations/18.0.2.0.0/pre-migrate.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright 2025 ACSONE SA/NV
2-
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
33
from openupgradelib import openupgrade
44

55

@@ -72,12 +72,14 @@ def migrate(env, version):
7272
env.cr, moved_model, "contract", new_module
7373
)
7474
all_moved_xml_ids = {
75-
"contract_line_successor": ["contract_line_wizard"],
75+
"contract_line_successor": [
76+
"contract_line_wizard",
77+
"contract_line_cron_for_renew",
78+
],
7679
"contract_termination": [
7780
"contract_terminate_reason_access_manager",
7881
"contract_terminate_reason_access_user",
7982
"can_terminate_contract",
80-
"can_terminate_contract",
8183
"contract_contract_terminate_wizard",
8284
],
8385
}

0 commit comments

Comments
 (0)