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. # Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
  2. # Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
  3. # Copyright 2015 Javier Iniesta <javieria@antiun.com>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from . import base
  6. from odoo.exceptions import ValidationError
  7. class ResPartnerCase(base.BaseCase):
  8. def test_count_mass_mailing_contacts(self):
  9. self.create_mailing_contact(
  10. {'email': 'partner@test.com',
  11. 'list_ids': [[6, 0, [self.mailing_list.id]]]})
  12. self.create_mailing_contact(
  13. {'email': 'partner@test.com',
  14. 'list_ids': [[6, 0, [self.mailing_list2.id]]]})
  15. self.assertEqual(self.partner.mass_mailing_contacts_count, 2)
  16. def test_write_res_partner(self):
  17. contact = self.create_mailing_contact(
  18. {'email': 'partner@test.com',
  19. 'list_ids': [[6, 0, [self.mailing_list.id]]]})
  20. self.assertEqual(self.partner, contact.partner_id)
  21. title_doctor = self.env.ref('base.res_partner_title_doctor')
  22. country_cu = self.env.ref('base.cu')
  23. category_8 = self.env.ref('base.res_partner_category_8')
  24. category_11 = self.env.ref('base.res_partner_category_11')
  25. self.partner.write({
  26. 'name': 'Changed', 'email': 'partner@changed.com',
  27. 'title': title_doctor.id, 'company_id': self.main_company.id,
  28. 'country_id': country_cu.id,
  29. 'category_id': [(6, 0, (category_8 | category_11).ids)],
  30. })
  31. self.check_mailing_contact_partner(contact)
  32. with self.assertRaises(ValidationError):
  33. self.partner.write({'email': False})