[FIX] website_sale: Explicitly ask to flag a SO as cart_recovery_email_sent

Purpose
=======

Now all the abandonned cart are marked as 'cart_recovery_email_sent' in any cases, whatever the email sent.

Specification
=============

The SO should be marked as 'cart_recovery_email_sent' only when the cart recovery email is sent.
This commit is contained in:
Yannick Tivisse
2017-09-25 10:50:28 +02:00
parent 2d442e6105
commit 23bf7fc7df
2 changed files with 4 additions and 4 deletions
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import datetime
from odoo import api, models
from odoo import api, fields, models
class MailComposeMessage(models.TransientModel):
_inherit = 'mail.compose.message'
@@ -12,10 +11,10 @@ class MailComposeMessage(models.TransientModel):
def send_mail(self, auto_commit=False):
context = self._context
# TODO TDE: clean that brole one day
if self.model == 'sale.order' and context.get('active_ids'):
if context.get('website_sale_send_recovery_email') and self.model == 'sale.order' and context.get('active_ids'):
self.env['sale.order'].search([
('id', 'in', context.get('active_ids')),
('cart_recovery_email_sent', '!=', True),
('cart_recovery_email_sent', '=', False),
('is_abandoned_cart', '=', True)
]).write({'cart_recovery_email_sent': True})
self = self.with_context(mail_post_autofollow=True)
+1
View File
@@ -225,6 +225,7 @@ class SaleOrder(models.Model):
'default_model': 'sale.order',
'default_use_template': bool(template_id),
'default_template_id': template_id,
'website_sale_send_recovery_email': True,
'active_ids': self.ids,
},
}