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.

45 lines
1.6 KiB

  1. # Copyright 2017-2019 Tecnativa - Pedro M. Baeza
  2. # License AGPL-3.0 or later (http://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(TestPartnerDeduplicateAcl, self).setUp()
  8. self.partner_1 = self.env['res.partner'].create({
  9. 'name': 'Partner 1',
  10. 'email': 'partner1@example.org',
  11. 'is_company': True,
  12. 'parent_id': False,
  13. })
  14. self.partner_2 = self.partner_1.copy()
  15. self.partner_2.write({
  16. 'name': 'Partner 1',
  17. 'email': 'partner2@example.org'
  18. })
  19. self.user = self.env['res.users'].create({
  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. self.wizard = self.env['base.partner.merge.automatic.wizard'].sudo(
  29. self.user,
  30. ).create({
  31. 'group_by_name': True,
  32. })
  33. def test_same_email_restriction(self):
  34. self.wizard.action_start_manual_process()
  35. with self.assertRaises(exceptions.UserError):
  36. self.wizard.action_merge()
  37. self.user.groups_id = [
  38. (4, self.env.ref('partner_deduplicate_acl.group_unrestricted').id),
  39. ]
  40. # Now there shouldn't be error
  41. self.wizard.action_merge()