-
-
Notifications
You must be signed in to change notification settings - Fork 810
Expand file tree
/
Copy pathend-migration.py
More file actions
33 lines (30 loc) · 868 Bytes
/
end-migration.py
File metadata and controls
33 lines (30 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version=None):
"""
Set consumed tours from legacy table after migration and
remove obsolete security rules.
"""
openupgrade.logged_query(
env.cr,
f"""
INSERT INTO res_users_web_tour_tour_rel
(res_users_id, web_tour_tour_id)
SELECT legacy_table.user_id, web_tour_tour.id
FROM
{openupgrade.get_legacy_name('web_tour_tour')} legacy_table,
web_tour_tour
WHERE web_tour_tour.name=legacy_table.name
ON CONFLICT DO NOTHING
""",
)
openupgrade.logged_query(
env.cr,
"""
DELETE FROM ir_rule
WHERE model_id = (
SELECT id FROM ir_model WHERE model = 'web_tour.tour'
)
AND domain_force LIKE '%user_id%';
""",
)