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.

30 lines
1.1 KiB

8 years ago
8 years ago
8 years ago
8 years ago
  1. # -*- coding: utf-8 -*-
  2. # © 2017 Sunflower IT <http://sunflowerweb.nl>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. from openerp import fields, models, api
  5. from ast import literal_eval
  6. class MergePartnerAutomatic(models.TransientModel):
  7. _inherit = 'base.partner.merge.automatic.wizard'
  8. # Enable deduplicating by reference
  9. group_by_ref = fields.Boolean('Reference')
  10. @api.multi
  11. def _process_query(self, query):
  12. ret = super(MergePartnerAutomatic, self)._process_query(query)
  13. # If 'extra_domain', deduplicate only the records matching the domain
  14. extra_domain = self.env.context.get('partner_merge_domain', [])
  15. if extra_domain:
  16. for line in self.line_ids:
  17. domain = [('id', 'in', literal_eval(line.aggr_ids))]
  18. domain.extend(extra_domain)
  19. aggr_ids = self.env['res.partner'].search(domain).ids
  20. if len(aggr_ids) > 1:
  21. line.aggr_ids = str(aggr_ids)
  22. else:
  23. line.unlink()
  24. return ret