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.

60 lines
2.2 KiB

  1. # Copyright 2016 Tecnativa - Pedro M. Baeza
  2. # Copyright 2018 Tecnativa - Cristina Martin
  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 TestDeduplicateByWebsite(common.SavepointCase):
  7. @classmethod
  8. def setUpClass(cls):
  9. super().setUpClass()
  10. cls.partner_1 = cls.env['res.partner'].with_context(
  11. tracking_disable=True).create({
  12. 'name': 'Partner 1',
  13. 'website': 'www.test-deduplicate.com',
  14. 'email': 'test@deduplicate.com',
  15. })
  16. def test_deduplicate_by_website(self):
  17. self.partner_2 = self.env['res.partner'].with_context(
  18. tracking_disable=True).create({
  19. 'name': 'Partner 2',
  20. 'website': 'www.test-deduplicate.com',
  21. 'email': 'test2@deduplicate.com',
  22. })
  23. wizard = self.env['base.partner.merge.automatic.wizard'].create({
  24. 'group_by_website': True,
  25. })
  26. wizard.action_start_manual_process()
  27. found_match = False
  28. for line in wizard.line_ids:
  29. match_ids = safe_eval(line.aggr_ids)
  30. if (self.partner_1.id in match_ids and
  31. self.partner_2.id in match_ids):
  32. found_match = True
  33. break
  34. self.assertTrue(found_match)
  35. def test_deduplicate_by_website_and_is_company(self):
  36. self.partner_2 = self.env['res.partner'].with_context(
  37. tracking_disable=True).create({
  38. 'name': 'Partner 2',
  39. 'website': 'www.test-deduplicate.com',
  40. 'email': 'test@deduplicate.com',
  41. })
  42. wizard = self.env['base.partner.merge.automatic.wizard'].create({
  43. 'group_by_website': True,
  44. 'group_by_email': True,
  45. })
  46. wizard.action_start_manual_process()
  47. found_match = False
  48. for line in wizard.line_ids:
  49. match_ids = safe_eval(line.aggr_ids)
  50. if (self.partner_1.id in match_ids and
  51. self.partner_2.id in match_ids):
  52. found_match = True
  53. break
  54. self.assertTrue(found_match)