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.

25 lines
766 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 ABF OSIELL <http://osiell.com>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openerp import api, SUPERUSER_ID
  5. def migrate_res_users_role(env):
  6. """Migrate user roles database schema.
  7. ('res_users_role_user_rel' many2many table to 'res.users.role.line' model.
  8. """
  9. role_line_model = env['res.users.role.line']
  10. query = "SELECT role_id, user_id FROM res_users_role_user_rel;"
  11. env.cr.execute(query)
  12. rows = env.cr.fetchall()
  13. for row in rows:
  14. vals = {
  15. 'role_id': row[0],
  16. 'user_id': row[1],
  17. }
  18. role_line_model.create(vals)
  19. def migrate(cr, version):
  20. env = api.Environment(cr, SUPERUSER_ID, {})
  21. migrate_res_users_role(env)