diff --git a/addons/crm/tests/__init__.py b/addons/crm/tests/__init__.py new file mode 100644 index 00000000000..69d299aea81 --- /dev/null +++ b/addons/crm/tests/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +import test_new_lead_notification diff --git a/addons/crm/tests/test_new_lead_notification.py b/addons/crm/tests/test_new_lead_notification.py new file mode 100644 index 00000000000..603889b2bc5 --- /dev/null +++ b/addons/crm/tests/test_new_lead_notification.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- + +from openerp.tests.common import TransactionCase + + +class NewLeadNotificationTest(TransactionCase): + def test_new_lead_notification(self): + # Create a new user + user = self.env["res.users"].create({ + "name": __file__, + "login": __file__, + }) + + # Subscribe him to sales department + team = self.env.ref("sales_team.section_sales_department") + subtype = self.env.ref("crm.mt_salesteam_lead") + team.sudo(user).message_subscribe_users(subtype_ids=[subtype.id]) + + # Imitate what happens in the controller when somebody creates a new + # lead from the website form + lead = (self.env["crm.lead"] + .with_context(mail_create_nosubscribe=True) + .sudo() + .create({"contact_name": "Somebody", + "description": "Some question", + "email_from": "somemail@example.com", + "name": "Some subject", + "partner_name": "Some company", + "section_id": self.env.ref( + "sales_team.section_sales_department").id, + "phone": "+0000000000"})) + + # The user should have a new unread message + self.assertTrue(lead.sudo(user).message_unread)