summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Beguin <dbe@odoo.com>2019-08-30 14:41:02 +0000
committerDavid Beguin <dbe@odoo.com>2019-09-17 14:12:21 +0000
commit858a92d2f2431125a75400c2bf11596dd76b7180 (patch)
tree7a7d8598e3da666fd7686f879ef9c9cc123b1aa9
parent7c842e7c9835050775d97a20de54335237892203 (diff)
[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
-rw-r--r--addons/website_crm_sms/__init__.py4
-rw-r--r--addons/website_crm_sms/__manifest__.py14
-rw-r--r--addons/website_crm_sms/models/__init__.py4
-rw-r--r--addons/website_crm_sms/models/website_visitor.py22
4 files changed, 44 insertions, 0 deletions
diff --git a/addons/website_crm_sms/__init__.py b/addons/website_crm_sms/__init__.py
new file mode 100644
index 00000000000..dc5e6b693d1
--- /dev/null
+++ b/addons/website_crm_sms/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import models
diff --git a/addons/website_crm_sms/__manifest__.py b/addons/website_crm_sms/__manifest__.py
new file mode 100644
index 00000000000..c4169ef7865
--- /dev/null
+++ b/addons/website_crm_sms/__manifest__.py
@@ -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,
+}
diff --git a/addons/website_crm_sms/models/__init__.py b/addons/website_crm_sms/models/__init__.py
new file mode 100644
index 00000000000..8c76c6becd2
--- /dev/null
+++ b/addons/website_crm_sms/models/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import website_visitor
diff --git a/addons/website_crm_sms/models/website_visitor.py b/addons/website_crm_sms/models/website_visitor.py
new file mode 100644
index 00000000000..57ce4281ff0
--- /dev/null
+++ b/addons/website_crm_sms/models/website_visitor.py
@@ -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