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.

17 lines
757 B

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 Akretion, Mourad EL HADJ MIMOUNE
  3. # Copyright 2018 Tecnativa - Pedro M. Baeza
  4. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  5. def pre_init_hook(cr):
  6. """If coming from v9 where only `sale_exception` is installed, when
  7. auto-installing this one by dependencies, we should take care of
  8. renaming previous table before the new model is loaded.
  9. """
  10. cr.execute("SELECT 1 FROM pg_class WHERE relname = 'sale_exception'")
  11. if not cr.fetchone():
  12. return # fresh install, so exiting
  13. from openupgradelib import openupgrade
  14. openupgrade.rename_tables(cr, [('sale_exception', 'exception_rule')])
  15. openupgrade.rename_models(cr, [('sale.exception', 'exception.rule')])