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.

32 lines
920 B

  1. # Copyright 2020 Creu Blanca
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from openupgradelib import openupgrade
  4. @openupgrade.migrate()
  5. def migrate(env, version):
  6. cr = env.cr
  7. if not openupgrade.column_exists(
  8. cr,
  9. 'custom_info_property',
  10. 'widget'
  11. ):
  12. openupgrade.add_fields(
  13. env,
  14. [('widget', 'custom.info.property', 'custom_info_property', 'char',
  15. False, 'base_custom_info')]
  16. )
  17. transform_values = [
  18. ('str', 'char'),
  19. ('int', 'integer'),
  20. ('bool', 'boolean'),
  21. ('float', 'float'),
  22. ('id', 'many2one')
  23. ]
  24. for field_type, widget in transform_values:
  25. cr.execute(
  26. "UPDATE custom_info_property SET widget = %s WHERE "
  27. "field_type = %s",
  28. (widget, field_type)
  29. )