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.

26 lines
920 B

  1. # Copyright 2020 NextERP Romania SRL
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
  3. from openupgradelib import openupgrade
  4. @openupgrade.migrate()
  5. def migrate(env, version):
  6. # Not tested
  7. properties = env["ir.property"].search(
  8. [
  9. (
  10. "fields_id",
  11. "=",
  12. env.ref("base.field_res_partner_property_comment_template_id").id,
  13. )
  14. ]
  15. )
  16. if properties:
  17. for template in properties.mapped("value_reference"):
  18. template_id = template.value_reference.split(",")[-1]
  19. if template_id:
  20. template = env["base.comment.template"].browse(template_id)
  21. part_prop = properties.filtered(lambda p: p.value_reference == template)
  22. template.partner_ids = [
  23. (prop["res_id"] or "").split(",")[-1] for prop in part_prop
  24. ]