hooks.py 639 B

12345678910111213141516171819
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2016 Tecnativa - Pedro M. Baeza
  3. # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
  4. def assign_contacts_team(cr, registry):
  5. """At installation time, propagate the parent sales team to the children
  6. contacts that have this field empty, as it's supposed that the intention
  7. is to have the same.
  8. """
  9. cr.execute(
  10. """
  11. UPDATE res_partner
  12. SET section_id=parent.section_id
  13. FROM res_partner AS parent
  14. WHERE parent.section_id IS NOT NULL
  15. AND res_partner.parent_id = parent.id
  16. AND res_partner.section_id IS NULL
  17. """)