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.

49 lines
1.7 KiB

  1. # Copyright 2017 Pedro M. Baeza <pedro.baeza@tecnativa.com>
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  3. from odoo.tests import common
  4. from odoo.tools.safe_eval import safe_eval
  5. class TestDeduplicateByRef(common.TransactionCase):
  6. def setUp(self):
  7. super().setUp()
  8. self.partner_1 = self.env['res.partner'].create({
  9. 'name': 'Partner 1',
  10. 'ref': '123456',
  11. 'email': 'test@deduplicate.com',
  12. })
  13. self.partner_2 = self.env['res.partner'].create({
  14. 'name': 'Partner 2',
  15. 'ref': '123456',
  16. 'email': 'test@deduplicate.com',
  17. })
  18. def test_deduplicate_by_ref(self):
  19. wizard = self.env['base.partner.merge.automatic.wizard'].create({
  20. 'group_by_ref': True,
  21. })
  22. wizard.action_start_manual_process()
  23. found_match = False
  24. for line in wizard.line_ids:
  25. match_ids = safe_eval(line.aggr_ids)
  26. if (self.partner_1.id in match_ids and
  27. self.partner_2.id in match_ids):
  28. found_match = True
  29. break
  30. self.assertTrue(found_match)
  31. def test_deduplicate_by_ref_and_is_company(self):
  32. wizard = self.env['base.partner.merge.automatic.wizard'].create({
  33. 'group_by_ref': True,
  34. 'group_by_email': True,
  35. })
  36. wizard.action_start_manual_process()
  37. found_match = False
  38. for line in wizard.line_ids:
  39. match_ids = safe_eval(line.aggr_ids)
  40. if (self.partner_1.id in match_ids and
  41. self.partner_2.id in match_ids):
  42. found_match = True
  43. break
  44. self.assertTrue(found_match)