Skip to content

Commit 90db3bd

Browse files
[OU-ADD] iap
1 parent 001aea8 commit 90db3bd

4 files changed

Lines changed: 81 additions & 1 deletion

File tree

docsource/modules170-180.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Module coverage 17.0 -> 18.0
224224
+---------------------------------------------------+----------------------+-------------------------------------------------+
225225
| http_routing |Nothing to do | |
226226
+---------------------------------------------------+----------------------+-------------------------------------------------+
227-
| iap | | |
227+
| iap |Done | |
228228
+---------------------------------------------------+----------------------+-------------------------------------------------+
229229
| iap_crm | |No DB layout changes. |
230230
+---------------------------------------------------+----------------------+-------------------------------------------------+
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 (https://www.gnu.org/licenses/agpl).
3+
4+
from openupgradelib import openupgrade
5+
6+
7+
@openupgrade.migrate()
8+
def migrate(env, version):
9+
openupgrade.logged_query(
10+
env.cr,
11+
f"""
12+
UPDATE iap_account ia
13+
SET service_id = ise.id
14+
FROM iap_service ise
15+
WHERE ia.service_id IS NULL AND
16+
ise.technical_name = ia.{openupgrade.get_legacy_name("service_name")}
17+
""",
18+
)
19+
openupgrade.logged_query(
20+
env.cr,
21+
f"""
22+
DELETE FROM iap_account
23+
WHERE service_id IS NULL
24+
AND {openupgrade.get_legacy_name("service_name")} IS NOT NULL
25+
""",
26+
)
27+
env["iap.account"]._add_sql_constraints()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2025 ForgeFlow S.L. (https://www.forgeflow.com)
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from openupgradelib import openupgrade
5+
6+
7+
@openupgrade.migrate()
8+
def migrate(env, version):
9+
openupgrade.logged_query(
10+
env.cr,
11+
"""
12+
UPDATE iap_account
13+
SET name = service_name
14+
WHERE COALESCE(name, '') != ''
15+
""",
16+
)
17+
openupgrade.rename_columns(env.cr, {"iap_account": [("service_name", None)]})
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---Models in module 'iap'---
2+
obsolete model iap.account.info [transient]
3+
new model iap.service
4+
# NOTHING TO DO: we don't rename it, as the transient model is emptied at base-pre-migration. Lets the ORM create the new model
5+
6+
---Fields in module 'iap'---
7+
iap / iap.account / account_info_ids (one2many) : DEL relation: iap.account.info
8+
iap / iap.account / balance (char) : is now stored
9+
iap / iap.account / balance (char) : not a function anymore
10+
iap / iap.account / service_locked (boolean) : NEW hasdefault: default
11+
iap / iap.account / show_token (boolean) : DEL
12+
iap / iap.account / state (selection) : NEW selection_keys: ['banned', 'registered', 'unregistered']
13+
iap / iap.account / warning_threshold (float) : is now stored
14+
iap / iap.account / warning_threshold (float) : not related anymore
15+
iap / iap.account / warning_user_ids (many2many) : NEW relation: res.users
16+
# NOTHING TO DO
17+
18+
iap / iap.account / service_name (char) : not stored anymore
19+
iap / iap.account / service_name (char) : now related
20+
# DONE: pre-migration: column renamed to save value (to use later to create the missing services)
21+
22+
iap / iap.account / service_id (many2one) : NEW relation: iap.service, required
23+
iap / iap.service / description (char) : NEW required
24+
iap / iap.service / integer_balance (boolean) : NEW required
25+
iap / iap.service / name (char) : NEW required
26+
iap / iap.service / technical_name (char) : NEW required
27+
iap / iap.service / unit_name (char) : NEW required
28+
# DONE: end-migration: create new service for each iap.account record and link them if the service don't exist
29+
30+
---XML records in module 'iap'---
31+
NEW iap.service: iap.iap_service_reveal
32+
NEW ir.model.access: iap.access_iap_service_manager
33+
NEW ir.model.access: iap.access_iap_service_user
34+
DEL ir.model.access: iap.access_iap_account_info
35+
NEW ir.model.constraint: iap.constraint_iap_service_unique_technical_name
36+
# NOTHING TO DO

0 commit comments

Comments
 (0)