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.

26 lines
799 B

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Iván Todorovich <ivan.todorovich@gmail.com>
  3. # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
  4. def migrate(cr, version):
  5. if version is None:
  6. return
  7. # Update ir.rule
  8. cr.execute("""
  9. SELECT res_id FROM ir_model_data
  10. WHERE name = 'model_tile_rule'
  11. AND module = 'web_dashboard_tile'""")
  12. rule_id = cr.fetchone()[0]
  13. new_domain = """[
  14. "|",
  15. ("user_id","=",user.id),
  16. ("user_id","=",False),
  17. "|",
  18. ("group_ids","=",False),
  19. ("group_ids","in",[g.id for g in user.groups_id]),
  20. ]"""
  21. cr.execute("""
  22. UPDATE ir_rule SET domain_force = '%(domain)s'
  23. WHERE id = '%(id)s' """ % {'domain': new_domain, 'id': rule_id})