[IMP] crm: filters for activity reporting
This commit improves the CRM reporting by: - adding new field on the report model - providing new predefined filters for users - renaming labels to be more precise - reorganizing filter and group by - remove wrong measure in report (probability and days to close), as they were not correct when multiple activity on a lead. Main purpose is to ease finding usefull KPI for the user, and make the activity reporting a bit less confusing and limited. It also now include all user messages (discussion subtype) and note from activity (when marking activity as done) in the reporting, so we can have a complete analysis of action taken on the leads. Task-1862209 closes odoo/odoo#27767
This commit is contained in:
@@ -12,34 +12,41 @@ class ActivityReport(models.Model):
|
||||
_description = "CRM Activity Analysis"
|
||||
_rec_name = 'id'
|
||||
|
||||
date = fields.Datetime('Date', readonly=True)
|
||||
author_id = fields.Many2one('res.partner', 'Created By', readonly=True)
|
||||
date = fields.Datetime('Completion Date', readonly=True)
|
||||
lead_create_date = fields.Datetime('Creation Date', readonly=True)
|
||||
date_conversion = fields.Datetime('Conversion Date', readonly=True)
|
||||
date_deadline = fields.Date('Expected Closing', readonly=True)
|
||||
date_closed = fields.Datetime('Closed Date', readonly=True)
|
||||
author_id = fields.Many2one('res.partner', 'Assigned To', readonly=True)
|
||||
user_id = fields.Many2one('res.users', 'Salesperson', readonly=True)
|
||||
team_id = fields.Many2one('crm.team', 'Sales Team', readonly=True)
|
||||
lead_id = fields.Many2one('crm.lead', "Lead", readonly=True)
|
||||
subject = fields.Char('Summary', readonly=True)
|
||||
lead_id = fields.Many2one('crm.lead', "Opportunity", readonly=True)
|
||||
body = fields.Html('Contents', readonly=True)
|
||||
subtype_id = fields.Many2one('mail.message.subtype', 'Subtype', readonly=True)
|
||||
mail_activity_type_id = fields.Many2one('mail.activity.type', 'Activity Type', readonly=True)
|
||||
country_id = fields.Many2one('res.country', 'Country', readonly=True)
|
||||
company_id = fields.Many2one('res.company', 'Company', readonly=True)
|
||||
stage_id = fields.Many2one('crm.stage', 'Stage', readonly=True)
|
||||
partner_id = fields.Many2one('res.partner', 'Partner/Customer', readonly=True)
|
||||
partner_id = fields.Many2one('res.partner', 'Customer', readonly=True)
|
||||
lead_type = fields.Char(
|
||||
string='Type',
|
||||
selection=[('lead', 'Lead'), ('opportunity', 'Opportunity')],
|
||||
help="Type is used to separate Leads and Opportunities")
|
||||
active = fields.Boolean('Active', readonly=True)
|
||||
probability = fields.Float('Probability', group_operator='avg', readonly=True)
|
||||
|
||||
def _select(self):
|
||||
return """
|
||||
SELECT
|
||||
m.id,
|
||||
l.create_date AS lead_create_date,
|
||||
l.date_conversion,
|
||||
l.date_deadline,
|
||||
l.date_closed,
|
||||
m.subtype_id,
|
||||
m.mail_activity_type_id,
|
||||
m.author_id,
|
||||
m.date,
|
||||
m.subject,
|
||||
m.body,
|
||||
l.id as lead_id,
|
||||
l.user_id,
|
||||
l.team_id,
|
||||
@@ -48,8 +55,7 @@ class ActivityReport(models.Model):
|
||||
l.stage_id,
|
||||
l.partner_id,
|
||||
l.type as lead_type,
|
||||
l.active,
|
||||
l.probability
|
||||
l.active
|
||||
"""
|
||||
|
||||
def _from(self):
|
||||
@@ -63,10 +69,11 @@ class ActivityReport(models.Model):
|
||||
"""
|
||||
|
||||
def _where(self):
|
||||
disccusion_subtype = self.env.ref('mail.mt_comment')
|
||||
return """
|
||||
WHERE
|
||||
m.model = 'crm.lead' AND m.mail_activity_type_id IS NOT NULL
|
||||
"""
|
||||
m.model = 'crm.lead' AND (m.mail_activity_type_id IS NOT NULL OR m.subtype_id = %s)
|
||||
""" % (disccusion_subtype.id,)
|
||||
|
||||
@api.model_cr
|
||||
def init(self):
|
||||
|
||||
@@ -23,41 +23,69 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="crm_activity_report_view_tree" model="ir.ui.view">
|
||||
<field name="name">crm.activity.report.tree</field>
|
||||
<field name="model">crm.activity.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree default_order="date desc">
|
||||
<field name="date"/>
|
||||
<field name="author_id"/>
|
||||
<field name="mail_activity_type_id"/>
|
||||
<field name="body" string="Activity Description"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="crm_activity_report_view_search" model="ir.ui.view">
|
||||
<field name="name">crm.activity.report.search</field>
|
||||
<field name="model">crm.activity.report</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Activities Analysis">
|
||||
<field name="mail_activity_type_id" string="Activity Type"/>
|
||||
<field name="lead_id" string="Opportunity"/>
|
||||
<field name="user_id" string="Salesperson"/>
|
||||
<field name="team_id" context="{'invisible_team': False}"/>
|
||||
<field name="author_id" string="Assigned To"/>
|
||||
<filter string="My Activities" name="activities_my" domain="[('user_id', '=', uid)]"/>
|
||||
<separator/>
|
||||
<filter name="lead" string="Leads" domain="[('lead_type','=', 'lead')]" help="Show only lead"/>
|
||||
<filter name="opportunity" string="Opportunities" domain="[('lead_type','=','opportunity')]" help="Show only opportunity"/>
|
||||
<separator groups="crm.group_use_lead"/>
|
||||
<filter name="lead" string="Leads" domain="[('lead_type','=', 'lead')]" help="Show only lead" groups="crm.group_use_lead"/>
|
||||
<filter name="opportunity" string="Opportunities" domain="[('lead_type','=','opportunity')]" help="Show only opportunity" groups="crm.group_use_lead"/>
|
||||
<separator/>
|
||||
<filter string="Won" name="won"
|
||||
domain="['&', ('stage_id.probability', '=', 100), ('stage_id.on_change', '=', 1)]"/>
|
||||
<separator/>
|
||||
<filter string="Date" name="filter_date" date="date"/>
|
||||
<field name="team_id" context="{'invisible_team': False}"/>
|
||||
<field name="author_id" string="Created By"/>
|
||||
<filter string="Completion Date" name="completion_date" date="date" default_period="last_365_days"/>
|
||||
<group expand="1" string="Group By">
|
||||
<filter string="Created By" name="group_by_salesperson" context="{'group_by':'author_id'}"/>
|
||||
<filter string="Subtype" name="group_by_subtype" context="{'group_by':'subtype_id'}"/>
|
||||
<filter string="Activity Type" name="group_by_activity_type" context="{'group_by':'mail_activity_type_id'}"/>
|
||||
<filter string="Assigned To" name="group_by_author_id" context="{'group_by':'author_id'}"/>
|
||||
<filter string="Completion Date" name="group_by_completion_date" context="{'group_by':'date:month'}"/>
|
||||
<separator/>
|
||||
<filter string="Salesperson" name="group_by_user_id" context="{'group_by':'user_id'}"/>
|
||||
<filter string="Sales Team" name="saleschannel" context="{'group_by':'team_id'}"/>
|
||||
<filter string="Country" name="country" context="{'group_by':'country_id'}" />
|
||||
<filter string="Company" name="company" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
|
||||
<filter string="Stage" name="stage" context="{'group_by':'stage_id'}"/>
|
||||
<filter string="Date" context="{'group_by':'date:month'}" name="month"/>
|
||||
<filter string="Leads" name="group_by_opportunity" context="{'group_by':'lead_id'}" />
|
||||
<filter string="Creation Date" name="group_by_lead_date_creation" context="{'group_by':'lead_create_date'}"/>
|
||||
<filter string="Company" name="company" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
|
||||
<filter string="Expected Closing" name="group_by_date_deadline" context="{'group_by':'date_deadline'}"/>
|
||||
<filter string="Closed Date" name="group_by_date_closed" context="{'group_by':'date_closed'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="crm_activity_report_action" model="ir.actions.act_window">
|
||||
<field name="name">Activities Analysis</field>
|
||||
<field name="name">Pipeline Activities</field>
|
||||
<field name="res_model">crm.activity.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,pivot</field>
|
||||
<field name="context">{'search_default_activities_my': True}</field>
|
||||
<field name="view_mode">graph,pivot,tree</field>
|
||||
<field name="context">{
|
||||
'search_default_activities_my': 1,
|
||||
'search_default_completion_date': 1,
|
||||
'pivot_column_groupby': ['subtype_id', 'mail_activity_type_id'],
|
||||
'pivot_row_groupby': ['date:month'],
|
||||
'graph_mode': 'bar',
|
||||
'graph_groupbys': ['date:month', 'subtype_id'],
|
||||
}</field>
|
||||
<field name="domain">[]</field>
|
||||
</record>
|
||||
|
||||
@@ -70,10 +98,10 @@
|
||||
sequence="3"/>
|
||||
|
||||
<record id="crm_activity_report_action_team" model="ir.actions.act_window">
|
||||
<field name="name">Activities Analysis</field>
|
||||
<field name="name">Pipeline Activities</field>
|
||||
<field name="res_model">crm.activity.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,pivot</field>
|
||||
<field name="view_mode">graph,pivot,tree</field>
|
||||
<field name="context">{'search_default_team_id': active_id}</field>
|
||||
<field name="domain">[]</field>
|
||||
</record>
|
||||
|
||||
@@ -65,6 +65,14 @@
|
||||
<field name="domain_force">['|',('user_id','=',user.id),('user_id','=',False)]</field>
|
||||
<field name="groups" eval="[(4, ref('sales_team.group_sale_salesman'))]"/>
|
||||
</record>
|
||||
|
||||
<record id="crm_activity_report_rule_multi_company" model="ir.rule">
|
||||
<field name="name">CRM Lead Multi-Company</field>
|
||||
<field name="model_id" ref="model_crm_activity_report"/>
|
||||
<field name="global" eval="True"/>
|
||||
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
<tree delete="false" create="false">
|
||||
<field name="author_id"/>
|
||||
<field name="subtype_id"/>
|
||||
<field name="subject"/>
|
||||
<field name="lead_id"/>
|
||||
<field name="date"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user