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.

56 lines
2.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 odoo.tests.common import TransactionCase
  6. class BaseCase(TransactionCase):
  7. def setUp(self):
  8. super(BaseCase, self).setUp()
  9. self.main_company = self.env.ref('base.main_company')
  10. self.country_es = self.env.ref('base.es')
  11. self.category_0 = self.env.ref('base.res_partner_category_0')
  12. self.category_1 = self.env.ref('base.res_partner_category_1')
  13. self.title_mister = self.env.ref('base.res_partner_title_mister')
  14. self.partner = self.create_partner(
  15. {'name': 'Partner test', 'email': 'partner@test.com',
  16. 'title': self.title_mister.id, 'company_id': self.main_company.id,
  17. 'country_id': self.country_es.id,
  18. 'category_id': [(6, 0, (self.category_0 | self.category_1).ids)]})
  19. self.category_3 = self.env.ref('base.res_partner_category_3')
  20. self.mailing_list = self.create_mailing_list({'name': 'List test'})
  21. self.mailing_list2 = self.create_mailing_list(
  22. {'name': 'List test 2', 'partner_mandatory': True,
  23. 'partner_category': self.category_3.id})
  24. def create_partner(self, vals):
  25. m_partner = self.env['res.partner']
  26. return m_partner.create(vals)
  27. def create_mailing_contact(self, vals):
  28. m_mailing_contact = self.env['mail.mass_mailing.contact']
  29. return m_mailing_contact.create(vals)
  30. def create_mailing_list(self, vals):
  31. m_mailing_list = self.env['mail.mass_mailing.list']
  32. return m_mailing_list.create(vals)
  33. def check_mailing_contact_partner(self, mailing_contact):
  34. if mailing_contact.partner_id:
  35. self.assertEqual(mailing_contact.partner_id.email,
  36. mailing_contact.email)
  37. self.assertEqual(mailing_contact.partner_id.name,
  38. mailing_contact.name)
  39. self.assertEqual(mailing_contact.partner_id.title,
  40. mailing_contact.title_id)
  41. if mailing_contact.partner_id.company_id:
  42. self.assertEqual(mailing_contact.partner_id.company_id.name,
  43. mailing_contact.company_name)
  44. self.assertEqual(mailing_contact.partner_id.country_id,
  45. mailing_contact.country_id)
  46. self.assertEqual(mailing_contact.partner_id.category_id,
  47. mailing_contact.tag_ids)