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.

31 lines
1.2 KiB

  1. # Copyright 2020 Ozono Multimedia S.L.L.
  2. # Copyright 2021 Simone Rubino - Agile Business Group
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  4. from openupgradelib import openupgrade
  5. @openupgrade.migrate()
  6. def migrate(env, version):
  7. """
  8. Column `move_type` of table `account_move` has been renamed to `financial_type`
  9. because `move_type` is now used by the core,
  10. so the column is moved during migration of module `account` in the core.
  11. Enterprise renames it to `move_type_custom`;
  12. OpenUpgrade renames it to its legacy name.
  13. Move data from the renamed column to the new `financial_type` column.
  14. """
  15. old_move_type_column = "move_type"
  16. new_move_type_column = "financial_type"
  17. move_table_name = "account_move"
  18. enterprise_move_type_rename = "move_type_custom"
  19. ou_move_type_rename = openupgrade.get_legacy_name(old_move_type_column)
  20. for move_type_rename in (enterprise_move_type_rename, ou_move_type_rename):
  21. if openupgrade.column_exists(env.cr, move_table_name, move_type_rename):
  22. openupgrade.rename_columns(
  23. env.cr,
  24. {
  25. move_table_name: [(move_type_rename, new_move_type_column)],
  26. },
  27. )
  28. break