[IMP] crm_iap_lead(_website): improve field naming

Purpose is to somehow clean naming of fields.

Task ID 2196182
PR #44662
Upgrade PR odoo/upgrade#973
This commit is contained in:
Thibault Delavallée
2020-04-21 12:28:52 +00:00
parent b415533dca
commit efafadc3ee
4 changed files with 10 additions and 10 deletions
@@ -42,7 +42,7 @@ class CRMLeadMiningRequest(models.Model):
user_id = fields.Many2one('res.users', string='Salesperson')
tag_ids = fields.Many2many('crm.tag', string='Tags')
lead_ids = fields.One2many('crm.lead', 'lead_mining_request_id', string='Generated Lead / Opportunity')
leads_count = fields.Integer(compute='_compute_leads_count', string='Number of Generated Leads')
lead_count = fields.Integer(compute='_compute_lead_count', string='Number of Generated Leads')
# Company Criteria Filter
filter_on_size = fields.Boolean(string='Filter on Size', default=False)
@@ -74,8 +74,8 @@ class CRMLeadMiningRequest(models.Model):
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):
@api.depends('lead_ids.lead_mining_request_id')
def _compute_lead_count(self):
if self.ids:
leads_data = self.env['crm.lead'].read_group(
[('lead_mining_request_id', 'in', self.ids)],
@@ -86,7 +86,7 @@ class CRMLeadMiningRequest(models.Model):
(m['lead_mining_request_id'][0], m['lead_mining_request_id_count'])
for m in leads_data)
for request in self:
request.leads_count = mapped_data.get(request.id, 0)
request.lead_count = mapped_data.get(request.id, 0)
@api.onchange('lead_number')
def _onchange_lead_number(self):
@@ -19,14 +19,14 @@
<button name="action_get_opportunity_action" class="oe_stat_button" type="object" icon="fa-handshake-o"
attrs="{'invisible': ['|', ('lead_type', '!=', 'opportunity'), ('state', '!=' , 'done')]}">
<div class="o_stat_info">
<field name="leads_count"/>
<field name="lead_count"/>
<span class="o_stat_text">Opportunities</span>
</div>
</button>
<button name="action_get_lead_action" class="oe_stat_button" type="object" icon="fa-handshake-o" groups="crm.group_use_lead"
attrs="{'invisible': ['|', ('lead_type', '!=', 'lead'), ('state', '!=' , 'done')]}">
<div class="o_stat_info">
<field name="leads_count"/>
<field name="lead_count"/>
<span class="o_stat_text">Leads</span>
</div>
</button>
@@ -57,7 +57,7 @@ class CRMRevealRule(models.Model):
user_id = fields.Many2one('res.users', string='Salesperson')
priority = fields.Selection(crm_stage.AVAILABLE_PRIORITIES, string='Priority')
lead_ids = fields.One2many('crm.lead', 'reveal_rule_id', string='Generated Lead / Opportunity')
leads_count = fields.Integer(compute='_compute_leads_count', string='Number of Generated Leads')
lead_count = fields.Integer(compute='_compute_lead_count', string='Number of Generated Leads')
opportunity_count = fields.Integer(compute='_compute_leads_count', string='Number of Generated Opportunity')
# This limits the number of extra contact.
@@ -101,7 +101,7 @@ class CRMRevealRule(models.Model):
self.clear_caches() # Clear the cache in order to recompute _get_active_rules
return super(CRMRevealRule, self).unlink()
def _compute_leads_count(self):
def _compute_lead_count(self):
leads = self.env['crm.lead'].read_group([
('reveal_rule_id', 'in', self.ids)
], fields=['reveal_rule_id', 'type'], groupby=['reveal_rule_id', 'type'], lazy=False)
@@ -13,9 +13,9 @@
<span class="o_stat_text"> Opportunities </span>
</div>
</button>
<button name="action_get_lead_tree_view" class="oe_stat_button" type="object" icon="fa-handshake-o" groups="crm.group_use_lead" attrs="{'invisible': [('lead_type', '!=', 'lead'), ('leads_count', '=' , 0)]}">
<button name="action_get_lead_tree_view" class="oe_stat_button" type="object" icon="fa-handshake-o" groups="crm.group_use_lead" attrs="{'invisible': [('lead_type', '!=', 'lead'), ('lead_count', '=' , 0)]}">
<div class="o_stat_info">
<field name="leads_count"/>
<field name="lead_count"/>
<span class="o_stat_text"> Leads </span>
</div>
</button>