You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.2 KiB

  1. from openupgradelib import openupgrade
  2. def update_records_module_category_cooperator_management(env):
  3. openupgrade.logged_query(
  4. env.cr,
  5. """
  6. UPDATE
  7. res_groups_users_rel_module_category_cooperator_management
  8. SET gid = (
  9. SELECT id
  10. FROM res_groups
  11. WHERE name = 'User'
  12. AND category_id = (
  13. SELECT id
  14. FROM ir_module_category
  15. WHERE name = 'Cooperative Management'
  16. )
  17. );""",
  18. )
  19. openupgrade.logged_query(
  20. env.cr,
  21. """
  22. INSERT INTO res_groups_users_rel (gid, uid)
  23. SELECT gid, uid FROM res_groups_users_rel_module_category_cooperator_management
  24. ON CONFLICT DO NOTHING;""",
  25. )
  26. def drop_records_module_category_cooperator_management(env):
  27. openupgrade.logged_query(
  28. env.cr,
  29. """
  30. DROP TABLE res_groups_users_rel_module_category_cooperator_management;""",
  31. )
  32. @openupgrade.migrate()
  33. def migrate(env, version):
  34. update_records_module_category_cooperator_management(env)
  35. drop_records_module_category_cooperator_management(env)