Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] crm_iap_lead*: generic improvements #32676

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions addons/crm_iap_lead/models/crm_iap_lead_mining_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,20 @@ def _default_lead_type(self):
seniority_id = fields.Many2one('crm.iap.lead.seniority', string='Seniority')

# Fields for the blue tooltip
lead_number_info = fields.Integer(string='Number of Leads ', related='lead_number', readonly=True)
lead_total_credit = fields.Integer(compute='_compute_lead_total_credit')
contact_credit_per_company = fields.Integer(compute='_compute_contact_credit_per_company')
contact_total_credit = fields.Integer(compute='_compute_contact_total_credit')

@api.depends('lead_number')
def _compute_lead_total_credit(self):
for req in self:
req.lead_total_credit = CREDIT_PER_COMPANY * req.lead_number

@api.depends('contact_number')
def _compute_contact_credit_per_company(self):
for req in self:
req.contact_credit_per_company = CREDIT_PER_CONTACT * req.contact_number

@api.depends('contact_number', 'lead_number')
def _compute_contact_total_credit(self):
for req in self:
req.contact_total_credit = CREDIT_PER_CONTACT * req.contact_number * req.lead_number
lead_credits = fields.Char(compute='_compute_credits', readonly=True)
lead_contacts_credits = fields.Char(compute='_compute_credits', readonly=True)

@api.onchange('lead_number', 'contact_number')
def _compute_tooltip(self):
for record in self:
total_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)

@api.depends('lead_ids')
def _compute_leads_count(self):
Expand Down Expand Up @@ -188,6 +183,12 @@ def _lead_vals_from_response(self, data):
lead_vals['lead_mining_request_id'] = self.id
return lead_vals

@api.model
def get_empty_list_help(self, help):
help_title = _('Create a Lead Mining Request')
sub_title = _('Generate new leads based on their country, industry, size, etc.')
return '<p class="o_view_nocontent_smiling_face">%s</p><p class="oe_view_nocontent_alias">%s</p>' % (help_title, sub_title)

@api.multi
def action_draft(self):
self.ensure_one()
Expand Down
12 changes: 2 additions & 10 deletions addons/crm_iap_lead/views/crm_iap_lead_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,10 @@
<div class="row">
<div class="col-md-6">
<div class="alert alert-info" role="alert">
Up to
<field name="lead_total_credit" class="mb0"/>
credits will be consumed to find
<field name="lead_number_info" class="mb0"/>
companies.
<field name="lead_credits"/>
<br/>
<span attrs="{'invisible': [('search_type', '!=', 'people')]}">
Up to
<field name="contact_credit_per_company" class="mb0"/>
additional credits will be consumed per company to identify contacts.
(<field name="contact_total_credit" class="mb0"/>)
<field name="lead_contacts_credits"/>
<br/>
</span>
</div>
Expand Down Expand Up @@ -175,7 +168,6 @@

<menuitem
id="crm_iap_lead_mining_request_menu_action"
name="Lead Mining"
action="crm_iap_lead_mining_request_action"
parent="crm_menu_lead_generation"
sequence="0"/>
Expand Down
1 change: 0 additions & 1 deletion addons/crm_iap_lead_website/views/crm_reveal_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@
id="crm_reveal_rule_menu_action"
action="crm_reveal_rule_action"
parent="crm_iap_lead.crm_menu_lead_generation"
name="Visits to Leads"
sequence="5"/>

<menuitem
Expand Down