Skip to content

Commit a21de6a

Browse files
committed
[ADD] tattoo_shop: tests on keys automations
task-4715882 closes #747 X-original-commit: 74970fe Signed-off-by: Vallaeys Valentin (vava) <[email protected]>
1 parent bcb1915 commit a21de6a

File tree

6 files changed

+57
-7
lines changed

6 files changed

+57
-7
lines changed

tattoo_shop/data/mail_template.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<record id="mail_template_after_care" model="mail.template">
44
<field name="body_html">
55
<![CDATA[<div data-oe-version="1.0">
6-
Hi <t t-out="object.display_name"/>,
6+
Hi <t t-out="object.contact_name" or ''/>,
77
<br/><br/>
88
We hope you had a nice experience at our Tattoo shop.
99
<br/>
@@ -20,7 +20,7 @@
2020
<record id="mail_template_booking_mail" model="mail.template">
2121
<field name="body_html">
2222
<![CDATA[<div data-oe-version="1.0">
23-
Hi <t t-out="object.display_name"/>,
23+
Hi <t t-out="object.contact_name" or ''/>,
2424
<br/><br/>
2525
Don't hesitate to book an appointment with us if you're interested in booking our services.
2626
<br/><br/>

tattoo_shop/i18n/tattoo_shop.pot

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#
55
msgid ""
66
msgstr ""
7-
"Project-Id-Version: Odoo Server saas~18.1+e\n"
7+
"Project-Id-Version: Odoo Server 18.0+e\n"
88
"Report-Msgid-Bugs-To: \n"
9-
"POT-Creation-Date: 2025-04-21 05:47+0000\n"
10-
"PO-Revision-Date: 2025-04-21 05:47+0000\n"
9+
"POT-Creation-Date: 2025-06-18 08:26+0000\n"
10+
"PO-Revision-Date: 2025-06-18 08:26+0000\n"
1111
"Last-Translator: \n"
1212
"Language-Team: \n"
1313
"MIME-Version: 1.0\n"
@@ -49,7 +49,7 @@ msgstr ""
4949
#: model:mail.template,body_html:tattoo_shop.mail_template_booking_mail
5050
msgid ""
5151
"<div data-oe-version=\"1.0\">\n"
52-
" Hi <t t-out=\"object.display_name\"/>,\n"
52+
" Hi <t t-out=\"object.contact_name\" or=\"\"/>,\n"
5353
" <br/><br/>\n"
5454
" Don't hesitate to book an appointment with us if you're interested in booking our services.\n"
5555
" <br/><br/>\n"
@@ -67,7 +67,7 @@ msgstr ""
6767
#: model:mail.template,body_html:tattoo_shop.mail_template_after_care
6868
msgid ""
6969
"<div data-oe-version=\"1.0\">\n"
70-
" Hi <t t-out=\"object.display_name\"/>,\n"
70+
" Hi <t t-out=\"object.contact_name\" or=\"\"/>,\n"
7171
" <br/><br/>\n"
7272
" We hope you had a nice experience at our Tattoo shop.\n"
7373
" <br/>\n"

tests/test_tattoo_shop/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
'name': 'Test Industry Tattoo Shop',
3+
'version': '1.0',
4+
'category': 'Hidden/Tests',
5+
'description': """A module to test code in the industry tattoo shop.""",
6+
'depends': ['base'],
7+
'license': 'LGPL-3',
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from . import test_action_server
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from odoo import fields
4+
from odoo.tests.common import TransactionCase
5+
from odoo.tests import tagged, Form
6+
7+
8+
@tagged('post_install', '-at_install')
9+
class TattooShopAutomationsTestCase(TransactionCase):
10+
@classmethod
11+
def setUpClass(cls):
12+
super().setUpClass()
13+
cls.partner = cls.env['res.partner'].create({
14+
'name': 'Tattoo Customer',
15+
'email': '[email protected]',
16+
})
17+
# Create a lead to use in tests
18+
cls.lead = cls.env['crm.lead'].create({
19+
'name': 'Tattoo Inquiry',
20+
'partner_id': cls.partner.id,
21+
'stage_id': cls.env.ref('crm.stage_lead1').id,
22+
})
23+
24+
def test_booking_link_sent_automation(self):
25+
nb_mail = self.env['mail.mail'].search_count([])
26+
# Trigger automation
27+
with Form(self.lead) as lead_form:
28+
lead_form.stage_id = self.env.ref('crm.stage_lead3')
29+
nb_mail_after = self.env['mail.mail'].search_count([])
30+
self.assertEqual(nb_mail_after, nb_mail + 1, "An email should be sent when the stage is changed to 'Booking Link Sent'")
31+
32+
def test_aftercare_automation(self):
33+
nb_mail = self.env['mail.mail'].search_count([])
34+
# Trigger automation
35+
with Form(self.lead) as lead_form:
36+
lead_form.stage_id = self.env.ref('tattoo_shop.crm_stage_7')
37+
nb_mail_after = self.env['mail.mail'].search_count([])
38+
self.assertEqual(nb_mail_after, nb_mail + 1, "An email should be sent when the stage is changed to 'Aftercare'")

0 commit comments

Comments
 (0)