diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/website_crm_sms | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/website_crm_sms')
| -rw-r--r-- | addons/website_crm_sms/__init__.py | 4 | ||||
| -rw-r--r-- | addons/website_crm_sms/__manifest__.py | 15 | ||||
| -rw-r--r-- | addons/website_crm_sms/models/__init__.py | 4 | ||||
| -rw-r--r-- | addons/website_crm_sms/models/website_visitor.py | 28 |
4 files changed, 51 insertions, 0 deletions
diff --git a/addons/website_crm_sms/__init__.py b/addons/website_crm_sms/__init__.py new file mode 100644 index 00000000..dc5e6b69 --- /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 00000000..f980ad2c --- /dev/null +++ b/addons/website_crm_sms/__manifest__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. +{ + 'name': 'Send SMS to Visitor with leads', + 'category': 'Website/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, + 'license': 'LGPL-3', +} diff --git a/addons/website_crm_sms/models/__init__.py b/addons/website_crm_sms/models/__init__.py new file mode 100644 index 00000000..8c76c6be --- /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 00000000..c6832542 --- /dev/null +++ b/addons/website_crm_sms/models/website_visitor.py @@ -0,0 +1,28 @@ +# -*- 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 _check_for_sms_composer(self): + check = super(WebsiteVisitor, self)._check_for_sms_composer() + if not check and self.lead_ids: + sorted_leads = self.lead_ids.filtered(lambda l: l.mobile == self.mobile or l.phone == self.mobile)._sort_by_confidence_level(reverse=True) + if sorted_leads: + return True + return check + + def _prepare_sms_composer_context(self): + if not self.partner_id and self.lead_ids: + 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 { + 'default_res_model': 'crm.lead', + 'default_res_id': lead.id, + 'number_field_name': 'mobile' if lead.mobile == self.mobile else 'phone', + } + return super(WebsiteVisitor, self)._prepare_sms_composer_context() |
