Skip to content
Permalink
Browse files

[ADD] website_crm_sms : send sms to visitor linked to a lead

This commit allows to send a sms to a visitor if the visitor
is linked to a least 1 lead that has a mobile number or a phone number.
As in contact form from website, there is only a phone field and not a mobile one,
we allow to send sms if the lead phone field is filled.
This is not very smart though.. But as 95% of the people around the world are
typing their mobile number into a phone field, this will do the work in a
statistically significative way.

Task ID: 2056080
PR #36290
  • Loading branch information...
dbeguin committed Aug 30, 2019
1 parent 2c2df62 commit afa096872ca4208e5b356c633944060f86969dde
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import models
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Send SMS to Visitor with leads',
'category': 'Website',
'sequence': 54,
'summary': 'Allows to send sms to website visitor that have lead',
'version': '1.0',
'description': """Allows to send sms to website visitor if the visitor is linked to a lead.""",
'depends': ['website_sms', 'crm'],
'data': [],
'installable': True,
'auto_install': True,
}
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import website_visitor
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import models


class WebsiteVisitor(models.Model):
_inherit = 'website.visitor'

def _prepare_visitor_send_sms_values(self):
visitor_sms_values = super(WebsiteVisitor, self)._prepare_visitor_send_sms_values()
if self.lead_ids:
lead = self.lead_ids.filtered(lambda l: l.mobile or l.phone)._sort_by_confidence_level(reverse=True)[0]
return {
'res_model': 'crm.lead',
'res_id': lead.id,
'partner_ids': [lead.id],
}
return visitor_sms_values

0 comments on commit afa0968

Please sign in to comment.
You can’t perform that action at this time.