[IMP]: Improve SQL view report for crm lead by adding fields. Also add #Accounts in account report.
bzr revid: rch_open_erp-20100428065428-svgm9aq7juqaalqa
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<field name="type" invisible="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="currency_mode" invisible="1"/>
|
||||
<field name="nbr" sum="#Accounts"/>
|
||||
<field name="user_type" invisible="1"/>
|
||||
<field name="credit" sum="Credit"/>
|
||||
<field name="debit" sum="Debit"/>
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
<field name="type_id" invisible="1"/>
|
||||
<field name="date_closed" invisible="1"/>
|
||||
<field name="date_open" invisible="1"/>
|
||||
<field name="opportunity_id" invisible="1"/>
|
||||
<field name="country_id" invisible="1"/>
|
||||
<field name="state_id" invisible="1"/>
|
||||
<field name="date_deadline" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -78,7 +82,16 @@
|
||||
<field name="priority" />
|
||||
<field name="type_id" widget="selection" domain="[('object_id.model', '=', 'crm.lead')]"/>
|
||||
<newline/>
|
||||
<field name="opportunity_id" />
|
||||
<field name="partner_id" />
|
||||
<separator orientation="vertical"/>
|
||||
<field name="country_id" />
|
||||
<field name="state_id" />
|
||||
<separator orientation="vertical"/>
|
||||
<field name="date_deadline" />
|
||||
<newline/>
|
||||
<field name="date_closed" />
|
||||
<separator orientation="vertical"/>
|
||||
<field name="date_open" />
|
||||
</group>
|
||||
</xpath>
|
||||
@@ -96,6 +109,16 @@
|
||||
context="{'group_by':'priority'}" />
|
||||
<filter string="Type" icon="terp-sale" domain="[]"
|
||||
context="{'group_by':'type_id'}" />
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Opportunity" icon="terp-sale" domain="[]"
|
||||
context="{'group_by':'opportunity_id'}" />
|
||||
<filter string="Partner" icon="terp-sale" domain="[]"
|
||||
context="{'group_by':'partner_id'}" />
|
||||
<newline/>
|
||||
<filter string="Country" icon="terp-sale" domain="[]"
|
||||
context="{'group_by':'country_id'}" />
|
||||
<filter string="State" icon="terp-sale" domain="[]"
|
||||
context="{'group_by':'state_id'}" />
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user