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
1.1 KiB

  1. # Copyright 2016 Tecnativa - Jairo Llopis
  2. # Copyright 2016 Tecnativa - Vicent Cubells
  3. # Copyright 2017 Tecnativa - Pedro M. Baeza
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from odoo import models
  6. class BasePartnerMergeAutomaticWizard(models.TransientModel):
  7. _inherit = "base.partner.merge.automatic.wizard"
  8. def _merge(self, partner_ids, dst_partner=None):
  9. """Perform the operation as admin if you have unrestricted merge
  10. rights to avoid the rise of exceptions. An special context key is
  11. passed for preserving the message author.
  12. """
  13. if self.env.user.has_group('partner_deduplicate_acl.group_unrestricted'):
  14. obj = self.sudo().with_context(message_post_user=self.env.uid)
  15. if dst_partner:
  16. dst_partner = dst_partner.with_context(
  17. message_post_user=self.env.uid,
  18. )
  19. else:
  20. obj = self
  21. return super(BasePartnerMergeAutomaticWizard, obj)._merge(
  22. partner_ids, dst_partner=dst_partner,
  23. )