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.

43 lines
1.6 KiB

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