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>
|
2020-02-10 11:40:11 +01:00
|
|
|
# Copyright 2020 Tecnativa - Manuel Calero
|
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
|
|
|
|
2017-06-14 20:47:41 +02:00
|
|
|
from odoo.tests.common import TransactionCase
|
2015-08-28 11:15:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
class BaseCase(TransactionCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(BaseCase, self).setUp()
|
2018-05-17 22:00:43 +02:00
|
|
|
|
2020-02-10 11:35:23 +01:00
|
|
|
self.main_company = self.env.ref("base.main_company")
|
|
|
|
self.country_es = self.env.ref("base.es")
|
|
|
|
self.category_0 = self.env.ref("base.res_partner_category_0")
|
|
|
|
self.category_2 = self.env.ref("base.res_partner_category_2")
|
|
|
|
self.title_mister = self.env.ref("base.res_partner_title_mister")
|
2018-05-17 22:00:43 +02:00
|
|
|
self.partner = self.create_partner(
|
2020-02-10 11:35:23 +01:00
|
|
|
{
|
|
|
|
"name": "Partner test",
|
|
|
|
"email": "partner@test.com",
|
|
|
|
"title": self.title_mister.id,
|
|
|
|
"company_id": self.main_company.id,
|
|
|
|
"country_id": self.country_es.id,
|
|
|
|
"category_id": [(6, 0, (self.category_0 | self.category_2).ids)],
|
|
|
|
}
|
|
|
|
)
|
2018-05-17 22:00:43 +02:00
|
|
|
|
2020-02-10 11:35:23 +01:00
|
|
|
self.category_3 = self.env.ref("base.res_partner_category_3")
|
|
|
|
self.mailing_list = self.create_mailing_list({"name": "List test"})
|
2018-05-17 22:00:43 +02:00
|
|
|
self.mailing_list2 = self.create_mailing_list(
|
2020-02-10 11:35:23 +01:00
|
|
|
{
|
|
|
|
"name": "List test 2",
|
|
|
|
"partner_mandatory": True,
|
|
|
|
"partner_category": self.category_3.id,
|
|
|
|
}
|
|
|
|
)
|
2015-08-28 11:15:50 +02:00
|
|
|
|
|
|
|
def create_partner(self, vals):
|
2020-02-10 11:35:23 +01:00
|
|
|
m_partner = self.env["res.partner"]
|
2015-08-28 11:15:50 +02:00
|
|
|
return m_partner.create(vals)
|
|
|
|
|
|
|
|
def create_mailing_contact(self, vals):
|
2020-02-10 11:40:11 +01:00
|
|
|
m_mailing_contact = self.env["mailing.contact"]
|
2015-08-28 11:15:50 +02:00
|
|
|
return m_mailing_contact.create(vals)
|
|
|
|
|
2018-05-17 22:00:43 +02:00
|
|
|
def create_mailing_list(self, vals):
|
2020-02-10 11:40:11 +01:00
|
|
|
m_mailing_list = self.env["mailing.list"]
|
2018-05-17 22:00:43 +02:00
|
|
|
return m_mailing_list.create(vals)
|
|
|
|
|
2015-08-28 11:15:50 +02:00
|
|
|
def check_mailing_contact_partner(self, mailing_contact):
|
|
|
|
if mailing_contact.partner_id:
|
2020-02-10 11:35:23 +01:00
|
|
|
self.assertEqual(mailing_contact.partner_id.email, mailing_contact.email)
|
|
|
|
self.assertEqual(mailing_contact.partner_id.name, mailing_contact.name)
|
|
|
|
self.assertEqual(mailing_contact.partner_id.title, mailing_contact.title_id)
|
2018-05-17 22:00:43 +02:00
|
|
|
if mailing_contact.partner_id.company_id:
|
2020-02-10 11:35:23 +01:00
|
|
|
self.assertEqual(
|
|
|
|
mailing_contact.partner_id.company_id.name,
|
|
|
|
mailing_contact.company_name,
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
mailing_contact.partner_id.country_id, mailing_contact.country_id
|
|
|
|
)
|
|
|
|
self.assertEqual(
|
|
|
|
mailing_contact.partner_id.category_id, mailing_contact.tag_ids
|
|
|
|
)
|