forked from alaguraj/odoo-testing-addons
implement reservation controller for slot availability and submission logic
This commit is contained in:
parent
3429feece9
commit
2e1b4358b1
@ -271,50 +271,61 @@ class TableReservationController(http.Controller):
|
|||||||
|
|
||||||
# Send Emails
|
# Send Emails
|
||||||
try:
|
try:
|
||||||
company_email = request.env.company.email or 'info@chennora.ca'
|
import logging
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# 1. Notify the Company
|
# Use the configured outgoing mail server's FROM address (must match SMTP username)
|
||||||
|
outgoing_server = request.env['ir.mail_server'].sudo().search([], limit=1)
|
||||||
|
smtp_from = outgoing_server.smtp_user if outgoing_server else 'alaguraj0361@gmail.com'
|
||||||
|
|
||||||
|
# 1. Notify the Company (Admin)
|
||||||
admin_mail_values = {
|
admin_mail_values = {
|
||||||
'subject': f"New Table Reservation: {customer_name}",
|
'subject': f"New Table Reservation: {customer_name}",
|
||||||
'body_html': f"""
|
'body_html': f"""
|
||||||
<p>A new table reservation has been submitted successfully.</p>
|
<div style="font-family: Arial, sans-serif; padding: 20px;">
|
||||||
<ul>
|
<h2 style="color: #2BB1A5;">New Table Reservation</h2>
|
||||||
<li><b>Customer Name:</b> {customer_name}</li>
|
<p>A new table reservation has been submitted from the website.</p>
|
||||||
<li><b>Phone:</b> {phone}</li>
|
<table style="width:100%; border-collapse: collapse;">
|
||||||
<li><b>Email:</b> {email}</li>
|
<tr><td style="padding:8px; font-weight:bold;">Customer Name:</td><td style="padding:8px;">{customer_name}</td></tr>
|
||||||
<li><b>Number of Guests:</b> {num_people}</li>
|
<tr><td style="padding:8px; font-weight:bold;">Phone:</td><td style="padding:8px;">{phone}</td></tr>
|
||||||
<li><b>Time:</b> {start_time_str}</li>
|
<tr><td style="padding:8px; font-weight:bold;">Email:</td><td style="padding:8px;">{email}</td></tr>
|
||||||
</ul>
|
<tr><td style="padding:8px; font-weight:bold;">Number of Guests:</td><td style="padding:8px;">{num_people}</td></tr>
|
||||||
|
<tr><td style="padding:8px; font-weight:bold;">Reservation Time:</td><td style="padding:8px;">{start_time_str}</td></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
""",
|
""",
|
||||||
'email_to': 'alaguraj0361@gmail.com',
|
'email_to': 'alaguraj0361@gmail.com',
|
||||||
'email_from': company_email,
|
'email_from': smtp_from,
|
||||||
'reply_to': email,
|
'reply_to': email,
|
||||||
}
|
}
|
||||||
admin_mail = request.env['mail.mail'].sudo().create(admin_mail_values)
|
admin_mail = request.env['mail.mail'].sudo().create(admin_mail_values)
|
||||||
admin_mail.send()
|
admin_mail.send()
|
||||||
|
_logger.info("Admin reservation notification sent to alaguraj0361@gmail.com")
|
||||||
|
|
||||||
# 2. Notify the Customer
|
# 2. Notify the Customer
|
||||||
customer_mail_values = {
|
customer_mail_values = {
|
||||||
'subject': f"Reservation Confirmation - Chennora",
|
'subject': "Reservation Confirmation - Chennora",
|
||||||
'body_html': f"""
|
'body_html': f"""
|
||||||
<p>Dear {customer_name},</p>
|
<div style="font-family: Arial, sans-serif; padding: 20px;">
|
||||||
<p>Your table reservation has been confirmed successfully!</p>
|
<h2 style="color: #2BB1A5;">Reservation Confirmed!</h2>
|
||||||
<p><b>Reservation Details:</b></p>
|
<p>Dear {customer_name},</p>
|
||||||
<ul>
|
<p>Your table reservation at <b>Chennora Indian Kitchen Bar</b> has been confirmed successfully!</p>
|
||||||
<li><b>Number of Guests:</b> {num_people}</li>
|
<table style="width:100%; border-collapse: collapse; margin-top: 15px;">
|
||||||
<li><b>Time:</b> {start_time_str}</li>
|
<tr><td style="padding:8px; font-weight:bold;">Number of Guests:</td><td style="padding:8px;">{num_people}</td></tr>
|
||||||
</ul>
|
<tr><td style="padding:8px; font-weight:bold;">Reservation Time:</td><td style="padding:8px;">{start_time_str}</td></tr>
|
||||||
<p>If you have any questions or need to make changes, please reply to this email.</p>
|
</table>
|
||||||
<br>
|
<p style="margin-top:20px;">If you need to make any changes or have questions, please reply to this email or call us at <b>+1(647)856-2878</b>.</p>
|
||||||
<p>We look forward to seeing you!</p>
|
<p>We look forward to seeing you!</p>
|
||||||
<p>Thank you,<br>Chennora</p>
|
<p>Thank you,<br><b>Chennora Indian Kitchen Bar</b></p>
|
||||||
|
</div>
|
||||||
""",
|
""",
|
||||||
'email_to': email,
|
'email_to': email,
|
||||||
'email_from': company_email,
|
'email_from': smtp_from,
|
||||||
'reply_to': 'info@chennora.ca',
|
'reply_to': smtp_from,
|
||||||
}
|
}
|
||||||
customer_mail = request.env['mail.mail'].sudo().create(customer_mail_values)
|
customer_mail = request.env['mail.mail'].sudo().create(customer_mail_values)
|
||||||
customer_mail.send()
|
customer_mail.send()
|
||||||
|
_logger.info("Customer reservation confirmation sent to %s", email)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import logging
|
import logging
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user