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.

27 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. # © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. try:
  5. from openupgradelib.openupgrade import rename_xmlids
  6. except ImportError:
  7. # Simplified version mostly copied from openupgradelib
  8. def rename_xmlids(cr, xmlids_spec):
  9. for (old, new) in xmlids_spec:
  10. if '.' not in old or '.' not in new:
  11. raise Exception(
  12. 'Cannot rename XMLID %s to %s: need the module '
  13. 'reference to be specified in the IDs' % (old, new))
  14. else:
  15. query = ("UPDATE ir_model_data SET module = %s, name = %s "
  16. "WHERE module = %s and name = %s")
  17. cr.execute(query, tuple(new.split('.') + old.split('.')))
  18. def migrate(cr, version):
  19. """Update database from previous versions, before updating module."""
  20. rename_xmlids(
  21. cr,
  22. (("website.mass_mail_unsubscription_" + r,
  23. "mass_mailing_custom_unsubscribe." + r)
  24. for r in ("success", "failure")))