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
828 B

  1. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  2. from . import models
  3. from odoo.tools.sql import column_exists
  4. def pre_init_hook(cr):
  5. if not column_exists(cr, "res_partner", "is_customer"):
  6. cr.execute(
  7. """
  8. ALTER TABLE res_partner
  9. ADD COLUMN is_customer boolean""",
  10. )
  11. cr.execute(
  12. """
  13. UPDATE res_partner
  14. SET is_customer = customer_rank::boolean
  15. """
  16. )
  17. if not column_exists(cr, "res_partner", "is_supplier"):
  18. cr.execute(
  19. """
  20. ALTER TABLE res_partner
  21. ADD COLUMN is_supplier boolean""",
  22. )
  23. cr.execute(
  24. """
  25. UPDATE res_partner
  26. SET is_supplier = supplier_rank::boolean
  27. """
  28. )