From f438daad1217c231fdb6a7526a963d0b38b723d5 Mon Sep 17 00:00:00 2001
From: "rch (Open ERP)" <>
Date: Wed, 28 Apr 2010 12:24:28 +0530
Subject: [PATCH] [IMP]: Improve SQL view report for crm lead by adding fields.
Also add #Accounts in account report.
bzr revid: rch_open_erp-20100428065428-svgm9aq7juqaalqa
---
.../account/report/account_account_report.py | 4 +++-
.../report/account_account_report_view.xml | 1 +
addons/crm/report/crm_lead_report.py | 9 ++++++++
addons/crm/report/crm_lead_report_view.xml | 23 +++++++++++++++++++
4 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/addons/account/report/account_account_report.py b/addons/account/report/account_account_report.py
index a872a7173e7..8a18c7d89f1 100644
--- a/addons/account/report/account_account_report.py
+++ b/addons/account/report/account_account_report.py
@@ -42,7 +42,8 @@ class account_account_report(osv.osv):
'user_type': fields.many2one('account.account.type', 'Account Type',readonly=True),
'credit': fields.float('Credit', readonly=True),
'debit': fields.float('Debit', readonly=True),
- 'balance': fields.float('Balance', readonly=True)
+ 'balance': fields.float('Balance', readonly=True),
+ 'nbr': fields.integer('#Accounts', readonly=True),
}
def init(self, cr):
tools.drop_view_if_exists(cr, 'account_account_report')
@@ -50,6 +51,7 @@ class account_account_report(osv.osv):
create or replace view account_account_report as (
select
min(a.id) as id,
+ count(distinct a.id) as nbr,
a.name,
a.code,
a.type as type,
diff --git a/addons/account/report/account_account_report_view.xml b/addons/account/report/account_account_report_view.xml
index 390fb144b0a..7388beb05f9 100644
--- a/addons/account/report/account_account_report_view.xml
+++ b/addons/account/report/account_account_report_view.xml
@@ -12,6 +12,7 @@
+
diff --git a/addons/crm/report/crm_lead_report.py b/addons/crm/report/crm_lead_report.py
index 92aeb7f28ec..fb30dd58182 100644
--- a/addons/crm/report/crm_lead_report.py
+++ b/addons/crm/report/crm_lead_report.py
@@ -54,6 +54,10 @@ class crm_lead_report(osv.osv):
('object_id.model', '=', 'crm.lead')]"),
'date_closed': fields.datetime('Closed', readonly=True),
'date_open': fields.datetime('Opened', readonly=True),
+ 'date_deadline': fields.date('Deadline', readonly=True),
+ 'opportunity_id': fields.many2one('crm.opportunity', 'Opportunity',readonly=True),
+ 'country_id': fields.many2one('res.country', 'Country' , readonly=True),
+ 'state_id': fields.many2one('res.country.state', 'State' , readonly=True)
}
def init(self, cr):
@@ -85,6 +89,10 @@ class crm_lead_report(osv.osv):
c.type_id as type_id,
c.date_closed as date_closed,
c.date_open as date_open,
+ c.opportunity_id as opportunity_id,
+ c.country_id as country_id,
+ c.state_id as state_id,
+ c.date_deadline as date_deadline,
date_trunc('day',c.create_date) as create_date,
avg(extract('epoch' from (c.date_closed-c.create_date)))/(3600*24) as delay_close
from
@@ -93,6 +101,7 @@ class crm_lead_report(osv.osv):
c.state, c.user_id,c.section_id,c.stage_id,categ_id,c.partner_id,c.company_id
,c.create_date,to_char(c.create_date, 'YYYY-MM-DD')
,c.priority,c.type_id,c.date_closed,c.date_open
+ ,c.opportunity_id,c.country_id,c.state_id,c.date_deadline
)""")
crm_lead_report()
diff --git a/addons/crm/report/crm_lead_report_view.xml b/addons/crm/report/crm_lead_report_view.xml
index 6ef0d90ac97..ab648d75ea2 100644
--- a/addons/crm/report/crm_lead_report_view.xml
+++ b/addons/crm/report/crm_lead_report_view.xml
@@ -26,6 +26,10 @@
+
+
+
+
@@ -78,7 +82,16 @@
+
+
+
+
+
+
+
+
+
@@ -96,6 +109,16 @@
context="{'group_by':'priority'}" />
+
+
+
+
+
+