[FIX] crm: added date_last_stage_update in crm + report
bzr revid: tde@openerp.com-20130717141336-ul8xwlveh3c1w9y9
This commit is contained in:
parent
707373ec9e
commit
b49d94408f
|
@ -246,11 +246,12 @@ class crm_lead(format_address, osv.osv):
|
|||
domain="['&', ('section_ids', '=', section_id), '|', ('type', '=', type), ('type', '=', 'both')]"),
|
||||
'user_id': fields.many2one('res.users', 'Salesperson', select=True, track_visibility='onchange'),
|
||||
'referred': fields.char('Referred By', size=64),
|
||||
'date_open': fields.datetime('Opened', readonly=True),
|
||||
'date_open': fields.datetime('Assigned', readonly=True),
|
||||
'day_open': fields.function(_compute_day, string='Days to Open', \
|
||||
multi='day_open', type="float", store=True),
|
||||
'day_close': fields.function(_compute_day, string='Days to Close', \
|
||||
multi='day_close', type="float", store=True),
|
||||
'date_last_stage_update': fields.datetime('Last Stage Update', select=True),
|
||||
|
||||
# Only used for type opportunity
|
||||
'probability': fields.float('Success Rate (%)', group_operator="avg"),
|
||||
|
@ -295,6 +296,7 @@ class crm_lead(format_address, osv.osv):
|
|||
'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.lead', context=c),
|
||||
'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0],
|
||||
'color': 0,
|
||||
'date_last_stage_update': fields.datetime.now(),
|
||||
}
|
||||
|
||||
_sql_constraints = [
|
||||
|
@ -678,7 +680,7 @@ class crm_lead(format_address, osv.osv):
|
|||
'phone': customer and customer.phone or lead.phone,
|
||||
}
|
||||
if not lead.stage_id or lead.stage_id.type=='lead':
|
||||
val['stage_id'] = self.stage_find(cr, uid, [lead], section_id, [('state', '=', 'draft'),('type', 'in', ('opportunity','both'))], context=context)
|
||||
val['stage_id'] = self.stage_find(cr, uid, [lead], section_id, [('sequence', '=', '1'), ('type', 'in', ('opportunity','both'))], context=context)
|
||||
return val
|
||||
|
||||
def convert_opportunity(self, cr, uid, ids, partner_id, user_ids=False, section_id=False, context=None):
|
||||
|
@ -918,6 +920,10 @@ class crm_lead(format_address, osv.osv):
|
|||
return super(crm_lead, self).create(cr, uid, vals, context=create_context)
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
# stage change: update date_last_stage_update
|
||||
if 'stage_id' in vals:
|
||||
vals['date_last_stage_update'] = fields.datetime.now()
|
||||
# stage change with new stage: update probability
|
||||
if vals.get('stage_id') and not vals.get('probability'):
|
||||
onchange_stage_values = self.onchange_stage_id(cr, uid, ids, vals.get('stage_id'), context=context)['value']
|
||||
vals.update(onchange_stage_values)
|
||||
|
|
|
@ -545,7 +545,7 @@
|
|||
<field name="section_id" context="{'invisible_section': False}" groups="base.group_multi_salesteams"/>
|
||||
<field name="user_id"/>
|
||||
<field name="partner_id" filter_domain="[('partner_id','child_of',self)]"/>
|
||||
<field name="stage_id"/>
|
||||
<field name="stage_id" domain="[]"/>
|
||||
<field name="probability"/>
|
||||
<separator/>
|
||||
<filter string="New" name="new"
|
||||
|
|
|
@ -58,8 +58,9 @@ class crm_lead_report(osv.osv):
|
|||
|
||||
# other date fields
|
||||
'create_date': fields.datetime('Create Date', readonly=True),
|
||||
'opening_date': fields.date('Opening Date', readonly=True),
|
||||
'opening_date': fields.date('Assignation Date', readonly=True),
|
||||
'date_closed': fields.date('Close Date', readonly=True),
|
||||
'date_last_stage_update': fields.datetime('Last Stage Update', readonly=True),
|
||||
|
||||
# durations
|
||||
'delay_open': fields.float('Delay to Assign',digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to open the case"),
|
||||
|
@ -97,7 +98,6 @@ class crm_lead_report(osv.osv):
|
|||
CREATE OR REPLACE VIEW crm_lead_report AS (
|
||||
SELECT
|
||||
id,
|
||||
|
||||
to_char(c.date_deadline, 'YYYY') as deadline_year,
|
||||
to_char(c.date_deadline, 'MM') as deadline_month,
|
||||
to_char(c.date_deadline, 'YYYY-MM-DD') as deadline_day,
|
||||
|
@ -109,6 +109,8 @@ class crm_lead_report(osv.osv):
|
|||
to_char(c.date_open, 'YYYY-MM-DD') as opening_date,
|
||||
to_char(c.date_closed, 'YYYY-mm-dd') as date_closed,
|
||||
|
||||
date_trunc('day',c.date_last_stage_update) as date_last_stage_update,
|
||||
|
||||
c.user_id,
|
||||
c.probability,
|
||||
c.stage_id,
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<field name="creation_month" invisible="1"/>
|
||||
<field name="creation_day" invisible="1"/>
|
||||
<field name="deadline_month" invisible="1"/>
|
||||
<field name="date_last_stage_update" invisible="1"/>
|
||||
<field name="stage_id" invisible="1"/>
|
||||
<field name="type_id" invisible="1"/>
|
||||
<field name="channel_id" invisible="1"/>
|
||||
|
@ -121,6 +122,7 @@
|
|||
<separator orientation="vertical" />
|
||||
<filter string="Exp. Closing" icon="terp-go-month"
|
||||
domain="[]" context="{'group_by':'deadline_month'}"/>
|
||||
<filter string="Last Stage Update" context="{'group_by':'date_last_stage_update'}" />
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
@ -152,6 +154,7 @@
|
|||
<field name="planned_revenue" sum="Planned Revenues"/>
|
||||
<field name="delay_open" sum='Delay to Assign'/>
|
||||
<field name="delay_close" sum='Delay to close'/>
|
||||
<field name="date_last_stage_update"/>
|
||||
<field name="delay_expected"/>
|
||||
<field name="probability" widget="progressbar"/>
|
||||
<field name="probable_revenue"/>
|
||||
|
|
Loading…
Reference in New Issue