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.

27 lines
830 B

  1. # Copyright 2019 Camptocamp SA
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
  3. import logging
  4. _logger = logging.getLogger(__name__)
  5. def pre_init_hook(cr):
  6. """Create column using SQL to avoid auto-init updating the table row by row
  7. :param odoo.sql_db.Cursor cr:
  8. Database cursor.
  9. """
  10. _logger.info(
  11. "Creating res.partner.partner_ref_unique column with value from "
  12. "res.company"
  13. )
  14. cr.execute("ALTER TABLE res_partner ADD partner_ref_unique varchar NULL;")
  15. cr.execute(
  16. "COMMENT ON COLUMN res_partner.partner_ref_unique "
  17. "IS 'Unique partner reference for';"
  18. )
  19. cr.execute(
  20. "UPDATE res_partner rp "
  21. "SET partner_ref_unique = rc.partner_ref_unique "
  22. "FROM res_company rc "
  23. "WHERE rc.id = rp.company_id;"
  24. )