vvrossem
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 137 additions and 0 deletions
-
42easy_my_coop/migrations/12.0.3.0.1/post-migration.py
-
82easy_my_coop/migrations/12.0.3.0.1/pre-migration.py
-
13website_recaptcha_reloaded/migrations/12.0.0.0.1/pre-migration.py
@ -0,0 +1,42 @@ |
|||||
|
from openupgradelib import openupgrade |
||||
|
|
||||
|
|
||||
|
def update_records_module_category_cooperator_management(env): |
||||
|
openupgrade.logged_query( |
||||
|
env.cr, |
||||
|
""" |
||||
|
UPDATE |
||||
|
res_groups_users_rel_module_category_cooperator_management |
||||
|
SET gid = ( |
||||
|
SELECT id |
||||
|
FROM res_groups |
||||
|
WHERE name = 'User' |
||||
|
AND category_id = ( |
||||
|
SELECT id |
||||
|
FROM ir_module_category |
||||
|
WHERE name = 'Cooperative Management' |
||||
|
) |
||||
|
);""", |
||||
|
) |
||||
|
|
||||
|
openupgrade.logged_query( |
||||
|
env.cr, |
||||
|
""" |
||||
|
INSERT INTO res_groups_users_rel (gid, uid) |
||||
|
SELECT gid, uid FROM res_groups_users_rel_module_category_cooperator_management |
||||
|
ON CONFLICT DO NOTHING;""", |
||||
|
) |
||||
|
|
||||
|
|
||||
|
def drop_records_module_category_cooperator_management(env): |
||||
|
openupgrade.logged_query( |
||||
|
env.cr, |
||||
|
""" |
||||
|
DROP TABLE res_groups_users_rel_module_category_cooperator_management;""", |
||||
|
) |
||||
|
|
||||
|
|
||||
|
@openupgrade.migrate() |
||||
|
def migrate(env, version): |
||||
|
update_records_module_category_cooperator_management(env) |
||||
|
drop_records_module_category_cooperator_management(env) |
@ -0,0 +1,82 @@ |
|||||
|
from openupgradelib import openupgrade |
||||
|
|
||||
|
xmlid_renames = [ |
||||
|
( |
||||
|
"easy_my_coop.group_energiris_user", |
||||
|
"easy_my_coop.group_easy_my_coop_user", |
||||
|
), |
||||
|
( |
||||
|
"easy_my_coop.group_energiris_manager", |
||||
|
"easy_my_coop.group_easy_my_coop_manager", |
||||
|
), |
||||
|
] |
||||
|
|
||||
|
|
||||
|
def copy_records_module_category_cooperator_management(env): |
||||
|
openupgrade.logged_query( |
||||
|
env.cr, |
||||
|
""" |
||||
|
CREATE TABLE res_groups_users_rel_module_category_cooperator_management AS |
||||
|
SELECT gid, uid |
||||
|
FROM res_groups_users_rel |
||||
|
WHERE gid = ( |
||||
|
SELECT id |
||||
|
FROM res_groups |
||||
|
WHERE name = 'User' |
||||
|
AND category_id = ( |
||||
|
SELECT id |
||||
|
FROM ir_module_category |
||||
|
WHERE name = 'EasyMy Coop' |
||||
|
) |
||||
|
) |
||||
|
ORDER BY gid,uid;""", |
||||
|
) |
||||
|
|
||||
|
|
||||
|
def delete_records_module_category_cooperator_management(env): |
||||
|
""""Since XML-ID module_category_cooperator_management is now flagged as noupdate="1", |
||||
|
we need to manually delete it as well as other records that are linked to it |
||||
|
""" |
||||
|
openupgrade.logged_query( |
||||
|
env.cr, |
||||
|
""" |
||||
|
DELETE |
||||
|
FROM res_groups_users_rel |
||||
|
WHERE gid = ( |
||||
|
SELECT id |
||||
|
FROM res_groups |
||||
|
WHERE name = 'User' |
||||
|
AND category_id = ( |
||||
|
SELECT id |
||||
|
FROM ir_module_category |
||||
|
WHERE name = 'EasyMy Coop' |
||||
|
) |
||||
|
);""", |
||||
|
) |
||||
|
openupgrade.logged_query( |
||||
|
env.cr, |
||||
|
""" |
||||
|
DELETE |
||||
|
FROM res_groups |
||||
|
WHERE name = 'User' |
||||
|
AND category_id = ( |
||||
|
SELECT id |
||||
|
FROM ir_module_category |
||||
|
WHERE name = 'EasyMy Coop' |
||||
|
);""", |
||||
|
) |
||||
|
openupgrade.logged_query( |
||||
|
env.cr, |
||||
|
""" |
||||
|
DELETE |
||||
|
FROM ir_module_category |
||||
|
WHERE name = 'EasyMy Coop';""", |
||||
|
) |
||||
|
|
||||
|
|
||||
|
@openupgrade.migrate() |
||||
|
def migrate(env, version): |
||||
|
cr = env.cr |
||||
|
openupgrade.rename_xmlids(cr, xmlid_renames) |
||||
|
copy_records_module_category_cooperator_management(env) |
||||
|
delete_records_module_category_cooperator_management(env) |
@ -0,0 +1,13 @@ |
|||||
|
from openupgradelib import openupgrade |
||||
|
|
||||
|
_field_renames = [ |
||||
|
("website", "website", "recaptcha_site_key", "recaptcha_key_site"), |
||||
|
("website", "website", "recaptcha_private_key", "recaptcha_key_secret"), |
||||
|
("res.config.settings", "res_config_settings", "recaptcha_site_key", "recaptcha_key_site"), |
||||
|
("res.config.settings", "res_config_settings", "recaptcha_private_key", "recaptcha_key_secret"), |
||||
|
] |
||||
|
|
||||
|
|
||||
|
@openupgrade.migrate() |
||||
|
def migrate(env, version): |
||||
|
openupgrade.rename_fields(env, _field_renames) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue