[IMP] crm: add conversion date in lead model that is the

date when the lead was converted into an opportunity.

Also added in opportunity aanlysis.
This commit is contained in:
Yannick Tivisse
2015-01-15 12:09:28 +01:00
committed by Thibault Delavallée
parent ff45ac8d36
commit d871d9a96d
4 changed files with 8 additions and 2 deletions
+2
View File
@@ -238,6 +238,7 @@ class crm_lead(format_address, osv.osv):
multi='day_open', type="float",
store={'crm.lead': (lambda self, cr, uid, ids, c={}: ids, ['date_closed'], 10)}),
'date_last_stage_update': fields.datetime('Last Stage Update', select=True),
'date_conversion': fields.datetime('Conversion Date', readonly=1),
# Messaging and marketing
'message_bounce': fields.integer('Bounce'),
@@ -701,6 +702,7 @@ class crm_lead(format_address, osv.osv):
'date_open': fields.datetime.now(),
'email_from': customer and customer.email or lead.email_from,
'phone': customer and customer.phone or lead.phone,
'date_conversion': fields.datetime.now(),
}
if not lead.stage_id or lead.stage_id.type=='lead':
val['stage_id'] = self.stage_find(cr, uid, [lead], team_id, [('type', 'in', ('opportunity', 'both'))], context=context)
+1
View File
@@ -468,6 +468,7 @@
<group>
<field name="tag_ids" widget="many2many_tags"/>
<field name="lost_reason"/>
<field name="date_conversion" invisible="1"/>
</group>
</group>
+3 -1
View File
@@ -61,6 +61,7 @@ class crm_opportunity_report(osv.Model):
('opportunity','Opportunity'),
],'Type', help="Type is used to separate Leads and Opportunities"),
'lost_reason': fields.many2one('crm.lost.reason', 'Lost Reason', readonly=True),
'date_conversion': fields.datetime('Conversion Date', readonly=True),
}
def init(self, cr):
@@ -95,7 +96,8 @@ class crm_opportunity_report(osv.Model):
extract('epoch' from (c.date_closed-c.create_date))/(3600*24) as delay_close,
abs(extract('epoch' from (c.date_deadline - c.date_closed))/(3600*24)) as delay_expected,
extract('epoch' from (c.date_open-c.create_date))/(3600*24) as delay_open,
c.lost_reason
c.lost_reason,
c.date_conversion as date_conversion
FROM
crm_lead c
WHERE c.active = 'true'
@@ -107,7 +107,8 @@
<filter string="Stage" context="{'group_by':'stage_id'}"/>
<separator orientation="vertical" />
<filter string="Creation Month" context="{'group_by':'create_date:month'}" name="month"/>
<filter string="Expected Closing" context="{'group_by':'date_deadline:month'}" name="month" help="Expiration Closing Month"/>
<filter string="Expected Closing" context="{'group_by':'date_deadline:month'}" name="date_deadline" help="Expiration Closing Month"/>
<filter string="Conversion Date" context="{'group_by':'date_conversion:month'}" name="conversion_date" help="Conversion Date from Lead to Opportunity"/>
<filter string="Lost Reason" context="{'group_by':'lost_reason'}"/>
</group>
</search>