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.

24 lines
786 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 SYLEAM
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from . import controllers
  5. from . import models
  6. import uuid
  7. def pre_init_hook(cr):
  8. """ Initialize oauth_identifier on res.users
  9. The standard initialization puts the same value for every existing record,
  10. which is invalid for this field.
  11. This is done in the pre_init_hook to be able to add the unique constrait
  12. on the first run, when installing the module.
  13. """
  14. cr.execute('ALTER TABLE res_users ADD COLUMN oauth_identifier varchar')
  15. cr.execute('SELECT id FROM res_users')
  16. for user_id in cr.fetchall():
  17. cr.execute(
  18. 'UPDATE res_users SET oauth_identifier = %s WHERE id = %s',
  19. (str(uuid.uuid4()), user_id))