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.

30 lines
986 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openupgradelib import openupgrade
  5. @openupgrade.migrate(use_env=True)
  6. def migrate(env, version):
  7. """If the system parameter exists before (manually created), don't error
  8. on duplicated record inserting manually the XML-ID entry before the
  9. loading.
  10. """
  11. param = env['ir.config_parameter'].search([
  12. ('key', '=', 'web_tree_many2one_clickable.default')
  13. ])
  14. if not param:
  15. return
  16. try:
  17. env.ref('web_tree_many2one_clickable.default')
  18. # XML-ID already exists - Nothing to do
  19. except ValueError:
  20. # Entry doesn't exist - Create it
  21. env['ir.model.data'].create({
  22. 'module': 'web_tree_many2one_clickable',
  23. 'name': 'default',
  24. 'model': 'ir.config_parameter',
  25. 'noupdate': True,
  26. 'res_id': param.id,
  27. })