2017-06-14 20:47:41 +02:00
|
|
|
# Copyright 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
|
|
|
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
|
|
|
|
# Copyright 2015 Javier Iniesta <javieria@antiun.com>
|
2016-08-08 13:14:37 +02:00
|
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
2015-08-28 11:15:50 +02:00
|
|
|
|
|
|
|
from . import base
|
2017-06-14 20:47:41 +02:00
|
|
|
from odoo.exceptions import ValidationError
|
2015-08-28 11:15:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ResPartnerCase(base.BaseCase):
|
|
|
|
|
|
|
|
def test_count_mass_mailing_contacts(self):
|
2018-05-17 22:00:43 +02:00
|
|
|
self.create_mailing_contact(
|
|
|
|
{'email': 'partner@test.com',
|
|
|
|
'list_ids': [[6, 0, [self.mailing_list.id]]]})
|
|
|
|
self.create_mailing_contact(
|
|
|
|
{'email': 'partner@test.com',
|
|
|
|
'list_ids': [[6, 0, [self.mailing_list2.id]]]})
|
2015-08-28 11:15:50 +02:00
|
|
|
self.assertEqual(self.partner.mass_mailing_contacts_count, 2)
|
|
|
|
|
|
|
|
def test_write_res_partner(self):
|
|
|
|
contact = self.create_mailing_contact(
|
2018-05-17 22:00:43 +02:00
|
|
|
{'email': 'partner@test.com',
|
|
|
|
'list_ids': [[6, 0, [self.mailing_list.id]]]})
|
|
|
|
self.assertEqual(self.partner, contact.partner_id)
|
|
|
|
|
|
|
|
title_doctor = self.env.ref('base.res_partner_title_doctor')
|
|
|
|
country_cu = self.env.ref('base.cu')
|
2018-11-09 13:24:39 +01:00
|
|
|
category_8 = self.env.ref('base.res_partner_category_8')
|
|
|
|
category_11 = self.env.ref('base.res_partner_category_11')
|
2018-05-17 22:00:43 +02:00
|
|
|
self.partner.write({
|
|
|
|
'name': 'Changed', 'email': 'partner@changed.com',
|
|
|
|
'title': title_doctor.id, 'company_id': self.main_company.id,
|
|
|
|
'country_id': country_cu.id,
|
2018-11-09 13:24:39 +01:00
|
|
|
'category_id': [(6, 0, (category_8 | category_11).ids)],
|
2018-01-16 11:05:09 +01:00
|
|
|
})
|
2018-05-17 22:00:43 +02:00
|
|
|
self.check_mailing_contact_partner(contact)
|
2015-08-28 11:15:50 +02:00
|
|
|
with self.assertRaises(ValidationError):
|
|
|
|
self.partner.write({'email': False})
|