From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/crm/report/__init__.py | 4 + addons/crm/report/crm_activity_report.py | 88 ++++++++++++ addons/crm/report/crm_activity_report_views.xml | 125 +++++++++++++++++ addons/crm/report/crm_opportunity_report_views.xml | 149 +++++++++++++++++++++ 4 files changed, 366 insertions(+) create mode 100644 addons/crm/report/__init__.py create mode 100644 addons/crm/report/crm_activity_report.py create mode 100644 addons/crm/report/crm_activity_report_views.xml create mode 100644 addons/crm/report/crm_opportunity_report_views.xml (limited to 'addons/crm/report') diff --git a/addons/crm/report/__init__.py b/addons/crm/report/__init__.py new file mode 100644 index 00000000..4b9eb202 --- /dev/null +++ b/addons/crm/report/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import crm_activity_report diff --git a/addons/crm/report/crm_activity_report.py b/addons/crm/report/crm_activity_report.py new file mode 100644 index 00000000..f9ce5907 --- /dev/null +++ b/addons/crm/report/crm_activity_report.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models, tools, api + + +class ActivityReport(models.Model): + """ CRM Lead Analysis """ + + _name = "crm.activity.report" + _auto = False + _description = "CRM Activity Analysis" + _rec_name = 'id' + + 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', "Opportunity", readonly=True) + body = fields.Html('Activity Description', 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', 'Customer', readonly=True) + lead_type = fields.Selection( + string='Type', + selection=[('lead', 'Lead'), ('opportunity', 'Opportunity')], + help="Type is used to separate Leads and Opportunities") + active = fields.Boolean('Active', 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.body, + l.id as lead_id, + l.user_id, + l.team_id, + l.country_id, + l.company_id, + l.stage_id, + l.partner_id, + l.type as lead_type, + l.active + """ + + def _from(self): + return """ + FROM mail_message AS m + """ + + def _join(self): + return """ + JOIN crm_lead AS l ON m.res_id = l.id + """ + + 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 OR m.subtype_id = %s) + """ % (disccusion_subtype.id,) + + def init(self): + tools.drop_view_if_exists(self._cr, self._table) + self._cr.execute(""" + CREATE OR REPLACE VIEW %s AS ( + %s + %s + %s + %s + ) + """ % (self._table, self._select(), self._from(), self._join(), self._where()) + ) diff --git a/addons/crm/report/crm_activity_report_views.xml b/addons/crm/report/crm_activity_report_views.xml new file mode 100644 index 00000000..987b865f --- /dev/null +++ b/addons/crm/report/crm_activity_report_views.xml @@ -0,0 +1,125 @@ + + + + + crm.activity.report.graph + crm.activity.report + + + + + + + + + + crm.activity.report.pivot + crm.activity.report + + + + + + + + + + crm.activity.report.tree + crm.activity.report + + + + + + + + + + + + + crm.activity.report.search + crm.activity.report + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Pipeline Activities + crm.activity.report + graph,pivot,tree + { + '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'], + } + [] + +

+ No data yet! +

+ Start scheduling activities on your opportunities +

+
+
+ + + + + Pipeline Activities + crm.activity.report + graph,pivot,tree + {'search_default_team_id': active_id} + [] + +

+ No data yet! +

+ Start scheduling activities on your opportunities +

+
+
+ +
diff --git a/addons/crm/report/crm_opportunity_report_views.xml b/addons/crm/report/crm_opportunity_report_views.xml new file mode 100644 index 00000000..85a4012e --- /dev/null +++ b/addons/crm/report/crm_opportunity_report_views.xml @@ -0,0 +1,149 @@ + + + + + + crm.opportunity.report.pivot + crm.lead + 60 + + + + + + + + + + + crm.opportunity.report.view.pivot.lead + crm.lead + 60 + + + + + + + + + + + crm.opportunity.report.graph + crm.lead + + + + + + + + + + + + crm.opportunity.report.graph.lead + crm.lead + 20 + + + + + + + + + + + + crm.lead.search + crm.lead + 32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Pipeline Analysis + crm.lead + pivot,graph,tree,form + + {'search_default_opportunity': True, 'search_default_current': True} + + Pipeline Analysis gives you an instant access to + your opportunities with information such as the expected revenue, planned cost, + missed deadlines or the number of interactions per opportunity. This report is + mainly used by the sales manager in order to do the periodic review with the + teams of the sales pipeline. + + + + + + + + Leads Analysis + crm.lead + pivot,graph,tree,form + + {'search_default_current': True, 'search_default_archived': True} + + This report analyses the source of your leads. + + + + + + + -- cgit v1.2.3