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.

25 lines
703 B

  1. # Copyright 2021 Open Source Integrators
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  3. import logging
  4. from odoo import SUPERUSER_ID, api
  5. _logger = logging.getLogger(__name__)
  6. def migrate(cr, version):
  7. env = api.Environment(cr, SUPERUSER_ID, {})
  8. stages = env["res.partner.stage"].search([])
  9. for stage in stages:
  10. _logger.info(
  11. "Migrating old state %s to stage_id %s...", stage.state, stage.name
  12. )
  13. cr.execute(
  14. """
  15. UPDATE res_partner
  16. SET stage_id = %(id)s, state = old_state
  17. WHERE old_state = %(state)s
  18. """,
  19. {"id": stage.id, "state": stage.state},
  20. )