[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
This commit is contained in:
@@ -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,22 @@
|
||||
# -*- 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 not visitor_sms_values:
|
||||
leads_with_number = self.lead_ids.filtered(lambda l: l.mobile == self.mobile or l.phone == self.mobile)._sort_by_confidence_level(reverse=True)
|
||||
if leads_with_number:
|
||||
lead = leads_with_number[0]
|
||||
return {
|
||||
'res_model': 'crm.lead',
|
||||
'res_id': lead.id,
|
||||
'partner_ids': [lead.id],
|
||||
'number_field_name': 'mobile' if lead.mobile == self.mobile else 'phone',
|
||||
}
|
||||
return visitor_sms_values
|
||||
Reference in New Issue
Block a user