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.

39 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
  3. # Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
  4. # Copyright 2015 Javier Iniesta <javieria@antiun.com>
  5. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  6. from . import base
  7. from odoo.exceptions import ValidationError
  8. class ResPartnerCase(base.BaseCase):
  9. def test_count_mass_mailing_contacts(self):
  10. self.create_mailing_contact({'email': 'partner@test.com',
  11. 'list_id': self.mailing_list.id})
  12. self.create_mailing_contact({'email': 'partner@test.com',
  13. 'list_id': self.mailing_list2.id})
  14. self.assertEqual(self.partner.mass_mailing_contacts_count, 2)
  15. def test_write_res_partner(self):
  16. user = self.env['res.users'].create({
  17. 'login': 'test',
  18. 'name': 'test',
  19. 'email': 'test@example.org',
  20. 'groups_id': [
  21. (4, self.env.ref('base.group_user').id),
  22. (4, self.env.ref('base.group_partner_manager').id),
  23. ]
  24. })
  25. contact = self.create_mailing_contact(
  26. {'email': 'partner@test.com', 'list_id': self.mailing_list.id})
  27. self.partner.sudo(user).write({
  28. 'name': 'Changed',
  29. 'email': 'partner@changed.com',
  30. })
  31. self.assertEqual(contact.name, self.partner.name)
  32. self.assertEqual(contact.email, self.partner.email)
  33. with self.assertRaises(ValidationError):
  34. self.partner.write({'email': False})