social/mail_activity_creator/tests/test_creator.py

45 lines
1.4 KiB
Python
Raw Normal View History

2020-02-03 16:16:50 +01:00
# Copyright 2020 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo.tests.common import TransactionCase
2020-02-03 16:16:50 +01:00
class TestCreator(TransactionCase):
def setUp(self):
super().setUp()
self.partner = self.env["res.partner"].create({"name": "DEMO"})
self.user_01 = self.env["res.users"].create(
{
"name": "user_01",
"login": "demo_user_01",
"email": "demo@demo.de",
"notification_type": "inbox",
}
)
self.model_id = self.env["ir.model"]._get("res.partner").id
self.activity_type = self.env["mail.activity.type"].create(
{
"name": "Initial Contact",
"delay_count": 5,
"summary": "ACT 1 : Presentation, barbecue, ... ",
"res_model_id": self.model_id,
}
)
2020-02-03 16:16:50 +01:00
def test_activity_creator(self):
activity = (
self.env["mail.activity"]
.with_user(self.user_01.id)
.create(
{
"activity_type_id": self.activity_type.id,
"note": "Partner activity 3.",
"res_id": self.partner.id,
"res_model_id": self.model_id,
"user_id": self.user_01.id,
}
)
)
2020-02-03 16:16:50 +01:00
self.assertEqual(activity.creator_uid, self.user_01)