diff options
| author | Aurélien Warnon <awa@odoo.com> | 2019-11-15 13:53:56 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-04-15 07:37:43 +0000 |
| commit | 9620721884c6e6983e5fae4cd8c1a0c21c197ff4 (patch) | |
| tree | 1fc00cb17dc330fedf5e6a418acc440e79d758f3 /addons/crm_iap_lead_enrich | |
| parent | 15b5b5f518e1a5654d7bc3c2b4b1d7311254b878 (diff) | |
[IMP] partner_autocomplete,crm_*: unify displayed "clearbit" information
PURPOSE
We make multiple calls to the clearbit API and the returned information are
shown in various different templates, although they contain the same
information.
The purpose of this commit is to unify the templates into a single one to
reduce code size and improve coherence.
SPECIFICATIONS
Currently, we have 3 ways of reaching out to the IAP clearbit api:
- When creating a partner (autocomplete service)
- When enriching an existing lead based on its email address
- When generating leads using the "Geneate Leads" button or using the website
visitors
Every time we use the service, we log a note in the model's chatter containing
all the information returned by the cleabit service (estimated annual revenue,
media links, sector, ...).
Though using different endpoints and methods, all the calls essentially return
the same data, and the templates could be unified for consistency.
This is the goal of this commit.
We merge the 3 separate templates of each modules into a unique template that
always renders the same information to the end user.
To do that, we had to find a common module to store the template, we chose
"partner_autocomplete" as it's installed anyway as soon as "crm_iap_lead_*" is
installed.
LINKS
PR #40349
Upgrade PR odoo/upgrade#775
Task 2081471
Diffstat (limited to 'addons/crm_iap_lead_enrich')
| -rw-r--r-- | addons/crm_iap_lead_enrich/__manifest__.py | 1 | ||||
| -rw-r--r-- | addons/crm_iap_lead_enrich/data/mail_data.xml | 73 | ||||
| -rw-r--r-- | addons/crm_iap_lead_enrich/models/crm_lead.py | 33 |
3 files changed, 9 insertions, 98 deletions
diff --git a/addons/crm_iap_lead_enrich/__manifest__.py b/addons/crm_iap_lead_enrich/__manifest__.py index 09369e9beea..e31676329d1 100644 --- a/addons/crm_iap_lead_enrich/__manifest__.py +++ b/addons/crm_iap_lead_enrich/__manifest__.py @@ -8,6 +8,7 @@ 'depends': [ 'iap', 'crm', + 'partner_autocomplete' ], 'data': [ 'data/ir_cron.xml', diff --git a/addons/crm_iap_lead_enrich/data/mail_data.xml b/addons/crm_iap_lead_enrich/data/mail_data.xml index 9f8482618ee..8a3c575a9e2 100644 --- a/addons/crm_iap_lead_enrich/data/mail_data.xml +++ b/addons/crm_iap_lead_enrich/data/mail_data.xml @@ -21,77 +21,4 @@ <span>Your balance for Lead Enrichment is insufficient. Please go to your <a t-attf-href="{{url}}" target="_blank">IAP account</a> to buy credits.</span> </div> </template> - - <template id="mail_message_lead_enrich_with_data"> - <p> - <span>Lead enriched based on email address</span> - </p> - <div style="background-color:#ffffff;padding:15px;"> - <table style="width:100%"> - <tr valign="top"> - <td></td> - <td rowspan="3"> - <img style="max-width: 80px;" t-attf-src="{{logo}}"/> - </td> - </tr> - <tr> - <td style="padding: 0 0 5px 0;"> - <span style="font-size:25px;vertical-align: middle;"> - <b><t t-esc="name"/></b> - </span> - <span style=""> - <a t-if="twitter" style="margin: 0 0 0 8px;" target="_blank" t-attf-href="http://www.twitter.com/{{twitter}}"> - <img src="/web_editor/font_to_img/61569/rgb(0,132,180)/22"/> - </a> - <a t-if="facebook" style="margin: 0 0 0 8px;" target="_blank" t-attf-href="http://www.facebook.com/{{facebook}}"> - <img src="/web_editor/font_to_img/61570/rgb(59,89,152)/22"/> - </a> - <a t-if="linkedin" style="margin: 0 0 0 8px;" target="_blank" t-attf-href="https://www.linkedin.com/{{linkedin}}"> - <img src="/web_editor/font_to_img/61580/rgb(0,119,181)/22"/> - </a> - <a t-if="crunchbase" style="margin: 0 0 0 8px;" target="_blank" t-attf-href="https://www.crunchbase.com/{{crunchbase}}"> - <img width="18px" height="18px" src="/crm_iap_lead/static/img/crunchbase.ico"/> - </a> - </span> - </td> - </tr> - <tr> - <td style="padding: 0 0 5px 0;"> - <span><t t-esc="description"/></span> - </td> - </tr> - <tr> - <td t-if="timezone" style="padding: 0 0 5px 0;"> - <img src="/web_editor/font_to_img/61463/rgb(135,90,123)/16"/> - <b>Timezone : </b> - <span><t t-esc="timezone"/></span> - <span> - <a target="_blank" t-att-href="timezone_url">(Time Now)</a> - </span> - </td> - </tr> - <tr> - <td t-if="phone_numbers" style="padding: 0 0 5px 0;"> - <img src="/web_editor/font_to_img/61589/rgb(135,90,123)/16"/> - <b>Phone :</b> - <t t-foreach="phone_numbers" t-as="phone_number"> - <span style="margin:0 5px;"> - <a target="_blank" t-attf-href="tel:{{phone_number}}"><t t-esc="phone_number"/></a> - </span> - </t> - </td> - </tr> - <tr> - <td t-if="tech" colspan="2"> - <b><img src="/web_editor/font_to_img/61874/rgb(135,90,123)/16"/> Technology Used :</b> - <t t-foreach="tech" t-as="t"> - <label style="font-weight:normal;padding: 2px 10px;background-color: #eeeeee;margin: 0 0 4px 2px;border-radius: 13px;"> - <t t-esc="t"/> - </label> - </t> - </td> - </tr> - </table> - </div> - </template> </data></odoo> diff --git a/addons/crm_iap_lead_enrich/models/crm_lead.py b/addons/crm_iap_lead_enrich/models/crm_lead.py index 86bc421c54a..5b7438b5e20 100644 --- a/addons/crm_iap_lead_enrich/models/crm_lead.py +++ b/addons/crm_iap_lead_enrich/models/crm_lead.py @@ -4,7 +4,7 @@ import datetime import logging -from odoo import api, fields, models, tools +from odoo import _, api, fields, models, tools from odoo.addons.iap import InsufficientCreditError _logger = logging.getLogger(__name__) @@ -87,8 +87,8 @@ class Lead(models.Model): continue values = {'iap_enrich_done': True} - lead_fields = ['description', 'partner_name', 'reveal_id', 'street', 'city', 'zip'] - iap_fields = ['description', 'name', 'clearbit_id', 'location', 'city', 'postal_code'] + lead_fields = ['partner_name', 'reveal_id', 'street', 'city', 'zip'] + iap_fields = ['name', 'clearbit_id', 'location', 'city', 'postal_code'] for lead_field, iap_field in zip(lead_fields, iap_fields): if not lead[lead_field] and iap_data.get(iap_field): values[lead_field] = iap_data[iap_field] @@ -110,28 +110,11 @@ class Lead(models.Model): values['state_id'] = state.id lead.write(values) + + template_values = iap_data + template_values['flavor_text'] = _("Lead enriched based on email address") lead.message_post_with_view( - 'crm_iap_lead_enrich.mail_message_lead_enrich_with_data', - values=lead._iap_enrich_get_message_data(iap_data), + 'partner_autocomplete.enrich_service_information', + values=template_values, subtype_id=self.env.ref('mail.mt_note').id ) - - def _iap_enrich_get_message_data(self, company_data): - log_data = { - 'name': company_data.get('name'), - 'description': company_data.get('description'), - 'twitter': company_data.get('twitter'), - 'logo': company_data.get('logo'), - 'phone_numbers': company_data.get('phone_numbers'), - 'facebook': company_data.get('facebook'), - 'linkedin': company_data.get('linkedin'), - 'crunchbase': company_data.get('crunchbase'), - 'tech': [t.replace('_', ' ').title() for t in company_data.get('tech', [])], - } - timezone = company_data.get('timezone') - if timezone: - log_data.update({ - 'timezone': timezone.replace('_', ' ').title(), - 'timezone_url': company_data.get('timezone_url'), - }) - return log_data |
