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_website | |
| 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_website')
| -rw-r--r-- | addons/crm_iap_lead_website/models/crm_reveal_rule.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/addons/crm_iap_lead_website/models/crm_reveal_rule.py b/addons/crm_iap_lead_website/models/crm_reveal_rule.py index 671aa6be16a..4da34077042 100644 --- a/addons/crm_iap_lead_website/models/crm_reveal_rule.py +++ b/addons/crm_iap_lead_website/models/crm_reveal_rule.py @@ -356,12 +356,20 @@ class CRMRevealRule(models.Model): # Does not create a lead if the reveal_id is already known return False lead_vals = rule._lead_vals_from_response(result) + lead = self.env['crm.lead'].create(lead_vals) + + template_values = result['reveal_data'] + template_values.update({ + 'flavor_text': _("Opportunity created by Odoo Lead Generation"), + 'people_data': result.get('people_data'), + }) lead.message_post_with_view( - 'crm_iap_lead.lead_message_template', - values=self.env['crm.iap.lead.helpers'].format_data_for_message_post(result['reveal_data'], result.get('people_data')), + 'partner_autocomplete.enrich_service_information', + values=template_values, subtype_id=self.env.ref('mail.mt_note').id ) + return lead # Methods responsible for format response data in to valid odoo lead data |
