[IMP] crm_iap_lead: improve credits tooltip

Before this commit, the tooltip message for the credits lacks clarity when making a request for companies and contacts. The sentence 'making a total of X credits for this request' was only the total of the credits for the contacts, without the credits for the companies.
Now, the tooltip is clearer, the total takes into account the credits for the companies and the contacts.

Task-ID 2036946

closes odoo/odoo#35049

Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
This commit is contained in:
Pierre Rousseau
2019-07-31 11:31:15 +00:00
parent 22223e144a
commit 0e6e80ca05
2 changed files with 6 additions and 6 deletions
@@ -62,18 +62,17 @@ class CRMLeadMiningRequest(models.Model):
# Fields for the blue tooltip
lead_credits = fields.Char(compute='_compute_tooltip', readonly=True)
lead_contacts_credits = fields.Char(compute='_compute_tooltip', readonly=True)
lead_total_credits = fields.Char(compute='_compute_tooltip', readonly=True)
@api.onchange('lead_number', 'contact_number')
def _compute_tooltip(self):
for record in self:
total_credits = CREDIT_PER_COMPANY * record.lead_number
company_credits = CREDIT_PER_COMPANY * record.lead_number
contact_credits = CREDIT_PER_CONTACT * record.contact_number
total_contact_credits = contact_credits * record.lead_number
message_contact = _("""Up to %d additional credits will be consumed
per company to identify its contacts (making a
total of %d credits for this request).""")
record.lead_credits = _('%d credits will be consumed to find %d companies.') % (total_credits, record.lead_number)
record.lead_contacts_credits = message_contact % (contact_credits, total_contact_credits)
record.lead_contacts_credits = _("Up to %d additional credits will be consumed to identify %d contacts per company.") % (contact_credits*company_credits, record.contact_number)
record.lead_credits = _('%d credits will be consumed to find %d companies.') % (company_credits, record.lead_number)
record.lead_total_credits = _("This makes a total of %d credits for this request.") % (total_contact_credits + company_credits)
@api.depends('lead_ids')
def _compute_leads_count(self):
@@ -91,6 +91,7 @@
<span attrs="{'invisible': [('search_type', '!=', 'people')]}">
<field name="lead_contacts_credits"/>
<br/>
<field name="lead_total_credits"/>
</span>
</div>
</div>