OCA reporting engine fork for dev and update.
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.

29 lines
1.2 KiB

  1. # Copyright 2021 Tecnativa - Víctor Martínez
  2. # Copyright 2021 Tecnativa - Pedro M. Baeza
  3. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  4. from openupgradelib import openupgrade
  5. from odoo.tools import parse_version
  6. @openupgrade.migrate()
  7. def migrate(env, version):
  8. if parse_version(version) == parse_version("14.0.1.0.0"):
  9. openupgrade.logged_query(
  10. env.cr,
  11. """
  12. INSERT INTO base_comment_template_res_partner_rel
  13. (res_partner_id, base_comment_template_id)
  14. SELECT SPLIT_PART(ip.res_id, ',', 2)::int AS res_partner_id,
  15. SPLIT_PART(ip.value_reference, ',', 2)::int AS base_comment_template_id
  16. FROM ir_property ip
  17. JOIN ir_model_fields imf ON ip.fields_id = imf.id
  18. JOIN res_partner rp ON rp.id = SPLIT_PART(ip.res_id, ',', 2)::int
  19. JOIN base_comment_template bct
  20. ON bct.id = SPLIT_PART(ip.value_reference, ',', 2)::int
  21. WHERE imf.name = 'property_comment_template_id'
  22. AND imf.model = 'res.partner'
  23. AND ip.res_id IS NOT NULL
  24. ON CONFLICT DO NOTHING
  25. """,
  26. )