diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 0c3047cf9fa..0d21dafcd33 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -663,18 +663,18 @@ class PurchaseOrder(models.Model): order.with_context(is_reminder=True).message_post_with_template(template.id, email_layout_xmlid="mail.mail_notification_paynow", composition_mode='comment') def send_reminder_preview(self): - if not self.user_has_groups('purchase.group_send_reminder') and not self.receipt_reminder_email: + self.ensure_one() + if not self.user_has_groups('purchase.group_send_reminder'): return template = self.env.ref('purchase.email_template_edi_purchase_reminder', raise_if_not_found=False) - if template and self.env.user.email: - for order in self: - template.with_context(is_reminder=True).send_mail( - order.id, - force_send=True, - raise_exception=False, - email_values={'email_to': self.env.user.email, 'recipient_ids': []}, - notif_layout="mail.mail_notification_paynow") + if template and self.env.user.email and self.id: + template.with_context(is_reminder=True).send_mail( + self.id, + force_send=True, + raise_exception=False, + email_values={'email_to': self.env.user.email, 'recipient_ids': []}, + notif_layout="mail.mail_notification_paynow") return {'toast_message': _("A sample email has been sent to %s.") % self.env.user.email} @api.model diff --git a/addons/purchase/static/src/js/purchase_toaster_button.js b/addons/purchase/static/src/js/purchase_toaster_button.js index 15820983c44..542858188dc 100644 --- a/addons/purchase/static/src/js/purchase_toaster_button.js +++ b/addons/purchase/static/src/js/purchase_toaster_button.js @@ -29,7 +29,9 @@ odoo.define('purchase.ToasterButton', function (require) { model: this.model, args: [[this.id]], }).then(res => { - this.do_notify(false, res.toast_message); + if (res) { + this.do_notify(false, res.toast_message); + } }) }, });