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.

71 lines
2.4 KiB

  1. # Copyright 2016 Tecnativa - Pedro M. Baeza
  2. # Copyright 2018 Tecnativa - Cristina Martin
  3. # License AGPL-3.0 or later (https://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 = (
  11. cls.env["res.partner"]
  12. .with_context(tracking_disable=True)
  13. .create(
  14. {
  15. "name": "Partner 1",
  16. "website": "www.test-deduplicate.com",
  17. "email": "test@deduplicate.com",
  18. }
  19. )
  20. )
  21. def test_deduplicate_by_website(self):
  22. self.partner_2 = (
  23. self.env["res.partner"]
  24. .with_context(tracking_disable=True)
  25. .create(
  26. {
  27. "name": "Partner 2",
  28. "website": "www.test-deduplicate.com",
  29. "email": "test2@deduplicate.com",
  30. }
  31. )
  32. )
  33. wizard = self.env["base.partner.merge.automatic.wizard"].create(
  34. {"group_by_website": 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 self.partner_2.id in match_ids:
  41. found_match = True
  42. break
  43. self.assertTrue(found_match)
  44. def test_deduplicate_by_website_and_is_company(self):
  45. self.partner_2 = (
  46. self.env["res.partner"]
  47. .with_context(tracking_disable=True)
  48. .create(
  49. {
  50. "name": "Partner 2",
  51. "website": "www.test-deduplicate.com",
  52. "email": "test@deduplicate.com",
  53. }
  54. )
  55. )
  56. wizard = self.env["base.partner.merge.automatic.wizard"].create(
  57. {"group_by_website": True, "group_by_email": True}
  58. )
  59. wizard.action_start_manual_process()
  60. found_match = False
  61. for line in wizard.line_ids:
  62. match_ids = safe_eval(line.aggr_ids)
  63. if self.partner_1.id in match_ids and self.partner_2.id in match_ids:
  64. found_match = True
  65. break
  66. self.assertTrue(found_match)