From cd9b47322948dda519230d25cf9ed31a3535f0c2 Mon Sep 17 00:00:00 2001 From: "Nasreddin Boulif (bon)" <bon@odoo.com> Date: Tue, 29 Aug 2023 10:34:00 +0200 Subject: [PATCH] [FIX] [sale_]loyalty: send gift card mail directly on SO confirmation Steps to reproduce: - Install Loyalty module - Go to Website and buy a gift card - Checkout and pay the order Issue: Only 'Order Confirmation' email is sent directly to the customer, gift card email is queued and sent later. Cause: `send_email` method is called with `force_send=False` by default, which queues the email to be sent later. Solution: Add optional parameter `send_force` (default to `False`) to `_send_creation_communication` method and call it with `send_force=True` when confirming a sale order. opw-3324386 closes odoo/odoo#133427 Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com> --- addons/loyalty/models/loyalty_card.py | 4 ++-- addons/sale_loyalty/models/sale_order.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/loyalty/models/loyalty_card.py b/addons/loyalty/models/loyalty_card.py index 1c387dbe5462..5259615a0902 100644 --- a/addons/loyalty/models/loyalty_card.py +++ b/addons/loyalty/models/loyalty_card.py @@ -100,7 +100,7 @@ class LoyaltyCard(models.Model): 'context': ctx, } - def _send_creation_communication(self): + def _send_creation_communication(self, force_send=False): """ Sends the 'At Creation' communication plan if it exist for the given coupons. """ @@ -114,7 +114,7 @@ class LoyaltyCard(models.Model): if not create_comm_per_program[coupon.program_id] or not coupon._get_mail_partner(): continue for comm in create_comm_per_program[coupon.program_id]: - comm.mail_template_id.send_mail(res_id=coupon.id, email_layout_xmlid='mail.mail_notification_light') + comm.mail_template_id.send_mail(res_id=coupon.id, force_send=force_send, email_layout_xmlid='mail.mail_notification_light') def _send_points_reach_communication(self, points_changes): """ diff --git a/addons/sale_loyalty/models/sale_order.py b/addons/sale_loyalty/models/sale_order.py index 95a1de13b0e7..c7271e43ee09 100644 --- a/addons/sale_loyalty/models/sale_order.py +++ b/addons/sale_loyalty/models/sale_order.py @@ -107,7 +107,7 @@ class SaleOrder(models.Model): for order in self: coupons |= order._get_reward_coupons() if coupons: - coupons._send_creation_communication() + coupons._send_creation_communication(force_send=True) def _get_applied_global_discount_lines(self): """ -- GitLab