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.

33 lines
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2015 Alexis de Lattre <alexis.delattre@akretion.com>
  3. # © 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  5. from openerp import api, SUPERUSER_ID
  6. import logging
  7. logger = logging.getLogger(__name__)
  8. def set_default_map_settings(cr, pool):
  9. """Method called as post-install script
  10. The default method on the field can't be used, because it would be executed
  11. before loading map_website_data.xml, so it would not be able to set a
  12. value"""
  13. with api.Environment.manage():
  14. env = api.Environment(cr, SUPERUSER_ID, {})
  15. user_model = env['res.users']
  16. users = user_model.search([])
  17. logger.info('Updating user settings for maps...')
  18. users.write({
  19. 'context_map_website_id': user_model._default_map_website().id,
  20. 'context_route_map_website_id': (
  21. user_model._default_route_map_website().id),
  22. })
  23. # Update the starting partner this way that is faster
  24. cr.execute("""
  25. UPDATE res_users
  26. SET context_route_start_partner_id = partner_id
  27. WHERE context_route_start_partner_id IS NULL;
  28. """)