[FIX] sale_coupon: batch confirmation of sales orders
`_send_reward_coupon_mail` is defined as `ensure_one` but is called on `self` in `action_confirm` which supports multiple records in self, thus raising a ValueError when confirming multiple sales orders together. This commit adapts the method to handle multiple records. FW-Port of odoo/enterprise#12161 closes odoo/odoo#56861 X-original-commit: 99c230c1c167d7369f8003c0219386799f92097d Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com> Co-authored-by: Alex Comba <alex.comba@agilebg.com>
This commit is contained in:
co-authored by
Alex Comba
parent
39358b9564
commit
e8697f6093
@@ -240,12 +240,13 @@ class SaleOrder(models.Model):
|
||||
def _send_reward_coupon_mail(self):
|
||||
template = self.env.ref('coupon.mail_template_sale_coupon', raise_if_not_found=False)
|
||||
if template:
|
||||
for coupon in self.generated_coupon_ids:
|
||||
self.message_post_with_template(
|
||||
template.id, composition_mode='comment',
|
||||
model='coupon.coupon', res_id=coupon.id,
|
||||
email_layout_xmlid='mail.mail_notification_light',
|
||||
)
|
||||
for order in self:
|
||||
for coupon in order.generated_coupon_ids:
|
||||
order.message_post_with_template(
|
||||
template.id, composition_mode='comment',
|
||||
model='coupon.coupon', res_id=coupon.id,
|
||||
email_layout_xmlid='mail.mail_notification_light',
|
||||
)
|
||||
|
||||
def _get_applicable_programs(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user