[IMP]Added cron for cart recovery mail and updated default value and configuration
This commit is contained in:
parent
89eea9a9d5
commit
28bfbb2c2e
@ -14,6 +14,7 @@
|
||||
'data/data.xml',
|
||||
'data/web_planner_data.xml',
|
||||
'data/mail_template_data.xml',
|
||||
'data/ir_cron_view.xml',
|
||||
'views/product_views.xml',
|
||||
'views/account_views.xml',
|
||||
'views/sale_report_views.xml',
|
||||
|
14
addons/website_sale/data/ir_cron_view.xml
Normal file
14
addons/website_sale/data/ir_cron_view.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<flectra>
|
||||
<data noupdate="1">
|
||||
<record forcecreate="True" id="cron_sale_cart_recovery" model="ir.cron">
|
||||
<field name="name">eCommerce: Cart Recovery Email Cron</field>
|
||||
<field name="model_id" ref="sale.model_sale_order"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model.send_cart_recovery_mail()</field>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">hours</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field eval="False" name="doall" />
|
||||
</record>
|
||||
</data>
|
||||
</flectra>
|
@ -72,6 +72,8 @@ class ResConfigSettings(models.TransientModel):
|
||||
cart_recovery_mail_template = literal_eval(params.get_param('website_sale.cart_recovery_mail_template_id', default='False'))
|
||||
if cart_recovery_mail_template and not self.env['mail.template'].browse(cart_recovery_mail_template).exists():
|
||||
cart_recovery_mail_template = self._default_recovery_mail_template()
|
||||
else:
|
||||
cart_recovery_mail_template = self._default_recovery_mail_template()
|
||||
|
||||
res.update(
|
||||
automatic_invoice=params.get_param('website_sale.automatic_invoice', default=False),
|
||||
|
@ -264,3 +264,19 @@ class SaleOrder(models.Model):
|
||||
res = super(SaleOrder, self)._prepare_invoice()
|
||||
res['website_id'] = self.website_id.id
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def send_cart_recovery_mail(self):
|
||||
for val in self.search([('state', 'in', ['draft', 'sent'])]):
|
||||
template = False
|
||||
try:
|
||||
template = self.env.ref(
|
||||
'website_sale.mail_template_sale_cart_recovery',
|
||||
raise_if_not_found=False)
|
||||
except ValueError:
|
||||
pass
|
||||
if val.partner_id.email and template and val.is_abandoned_cart \
|
||||
and not val.cart_recovery_email_sent:
|
||||
template.with_context(lang=val.partner_id.lang).send_mail(
|
||||
val.id, force_send=True, raise_exception=True)
|
||||
val.cart_recovery_email_sent = True
|
||||
|
Loading…
Reference in New Issue
Block a user