[IMP] crm: implement digest KPIs / tips
Purpose of this commit is send lead / opportunity creation as well as won opportunities KPIs in digest emails. Those are added in the default digest template. A tip to remind to use the mailgateway is also integrated. This commit is linked to task ID 30655 and PR #18318.
This commit is contained in:
committed by
Thibault Delavallée
parent
9751417102
commit
707bd1bfb4
@@ -18,7 +18,8 @@
|
||||
'fetchmail',
|
||||
'utm',
|
||||
'web_tour',
|
||||
'contacts'
|
||||
'contacts',
|
||||
'digest',
|
||||
],
|
||||
'data': [
|
||||
'security/crm_security.xml',
|
||||
@@ -28,6 +29,7 @@
|
||||
'data/crm_stage_data.xml',
|
||||
'data/crm_lead_data.xml',
|
||||
'data/mail_template_data.xml',
|
||||
'data/digest_data.xml',
|
||||
|
||||
'wizard/crm_lead_lost_views.xml',
|
||||
'wizard/crm_lead_to_opportunity_views.xml',
|
||||
@@ -44,6 +46,7 @@
|
||||
'report/crm_opportunity_report_views.xml',
|
||||
'views/crm_team_views.xml',
|
||||
'views/res_users_views.xml',
|
||||
'views/digest_views.xml',
|
||||
],
|
||||
'demo': [
|
||||
'data/crm_demo.xml',
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
<record id="digest.digest_digest_default" model="digest.digest">
|
||||
<field name="kpi_crm_lead_created">True</field>
|
||||
<field name="kpi_crm_opportunities_won">True</field>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
<data>
|
||||
<record id="digest_tip_crm_0" model="digest.tip">
|
||||
<field name="sequence">2</field>
|
||||
<field name="group_id" ref="sales_team.group_sale_salesman_all_leads"/>
|
||||
<field name="tip_description" type="html">
|
||||
<div>
|
||||
% set email = object.env['crm.team'].search([('alias_name','!=', False)],limit=1).alias_id.display_name
|
||||
% if email
|
||||
<strong style="font-size: 16px;">Try the mail gateway</strong>
|
||||
<div style="font-size: 14px;">Email sent to <strong>${email}</strong> generate opportunities in your pipeline.<br/>
|
||||
<div style="text-align:center;margin-top:5px;margin-bottom:2px;">
|
||||
<a href="mailto:${email}" style="background-color:#56b3b5;padding:2px;color:#FFFFFF;font-weight:bold;text-decoration:none;">Try Now</a>
|
||||
</div>
|
||||
</div>
|
||||
% endif
|
||||
</div>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
@@ -8,3 +8,4 @@ from . import crm_stage
|
||||
from . import crm_team
|
||||
from . import res_config_settings
|
||||
from . import res_partner
|
||||
from . import digest
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import AccessError
|
||||
|
||||
|
||||
class Digest(models.Model):
|
||||
_inherit = 'digest.digest'
|
||||
|
||||
kpi_crm_lead_created = fields.Boolean('New Leads/Opportunities')
|
||||
kpi_crm_lead_created_value = fields.Integer(compute='_compute_kpi_crm_lead_created_value')
|
||||
kpi_crm_opportunities_won = fields.Boolean('Opportunities Won')
|
||||
kpi_crm_opportunities_won_value = fields.Integer(compute='_compute_kpi_crm_opportunities_won_value')
|
||||
|
||||
def _compute_kpi_crm_lead_created_value(self):
|
||||
if not self.env.user.has_group('sales_team.group_sale_salesman'):
|
||||
raise AccessError(_("Do not have access, skip this data for user's digest email"))
|
||||
for record in self:
|
||||
start, end, company = record._get_kpi_compute_parameters()
|
||||
record.kpi_crm_lead_created_value = self.env['crm.lead'].search_count([
|
||||
('create_date', '>=', start),
|
||||
('create_date', '<', end),
|
||||
('company_id', '=', company.id)
|
||||
])
|
||||
|
||||
def _compute_kpi_crm_opportunities_won_value(self):
|
||||
if not self.env.user.has_group('sales_team.group_sale_salesman'):
|
||||
raise AccessError(_("Do not have access, skip this data for user's digest email"))
|
||||
for record in self:
|
||||
start, end, company = record._get_kpi_compute_parameters()
|
||||
record.kpi_crm_opportunities_won_value = self.env['crm.lead'].search_count([
|
||||
('type', '=', 'opportunity'),
|
||||
('probability', '=', '100'),
|
||||
('date_closed', '>=', start),
|
||||
('date_closed', '<', end),
|
||||
('company_id', '=', company.id)
|
||||
])
|
||||
|
||||
def compute_kpis_actions(self, company, user):
|
||||
res = super(Digest, self).compute_kpis_actions(company, user)
|
||||
res['kpi_crm_lead_created'] = 'crm.crm_lead_opportunities_tree_view&menu_id=%s' % self.env.ref('crm.crm_menu_root').id
|
||||
res['kpi_crm_opportunities_won'] = 'crm.crm_lead_opportunities_tree_view&menu_id=%s' % self.env.ref('crm.crm_menu_root').id
|
||||
if user.has_group('crm.group_use_lead'):
|
||||
res['kpi_crm_lead_created'] = 'crm.crm_lead_all_leads&menu_id=%s' % self.env.ref('crm.crm_menu_root').id
|
||||
return res
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<odoo>
|
||||
<record id="digest_digest_view_form" model="ir.ui.view">
|
||||
<field name="name">digest.digest.view.form.inherit.crm.lead</field>
|
||||
<field name="model">digest.digest</field>
|
||||
<field name="inherit_id" ref="digest.digest_digest_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//group[@name='kpi_general']" position="after">
|
||||
<group name="kpi_crm" string="CRM" groups="sales_team.group_sale_salesman_all_leads">
|
||||
<field name="kpi_crm_lead_created"/>
|
||||
<field name="kpi_crm_opportunities_won"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user