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.

46 lines
1.6 KiB

  1. # Copyright 2017-2019 Tecnativa - Pedro M. Baeza
  2. # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
  3. from odoo import exceptions
  4. from odoo.tests import common
  5. class TestPartnerDeduplicateAcl(common.TransactionCase):
  6. def setUp(self):
  7. super().setUp()
  8. self.partner_1 = self.env["res.partner"].create(
  9. {
  10. "name": "Partner 1",
  11. "email": "partner1@example.org",
  12. "is_company": True,
  13. "parent_id": False,
  14. }
  15. )
  16. self.partner_2 = self.partner_1.copy()
  17. self.partner_2.write({"name": "Partner 1", "email": "partner2@example.org"})
  18. self.user = self.env["res.users"].create(
  19. {
  20. "login": "test_crm_deduplicate_acl",
  21. "name": "test_crm_deduplicate_acl",
  22. "email": "partner_deduplicate_acl@example.org",
  23. "groups_id": [
  24. (4, self.env.ref("base.group_user").id),
  25. (4, self.env.ref("base.group_partner_manager").id),
  26. ],
  27. }
  28. )
  29. self.wizard = (
  30. self.env["base.partner.merge.automatic.wizard"]
  31. .with_user(self.user)
  32. .create({"group_by_name": True})
  33. )
  34. def test_same_email_restriction(self):
  35. self.wizard.action_start_manual_process()
  36. with self.assertRaises(exceptions.UserError):
  37. self.wizard.action_merge()
  38. self.user.groups_id = [
  39. (4, self.env.ref("partner_deduplicate_acl.group_unrestricted").id)
  40. ]
  41. # Now there shouldn't be error
  42. self.wizard.action_merge()