[REV] crm: reverted most changes about stages for this branch.
We keep fold, because it has a meaning in kanban view, and is kind of 'drop' stage, for won / lost / cancel / dead. New stage is now the stage with the lower sequence, not necessarily the stage with sequence 1. Note that this could break the _track because it checks for stages with sequence <= 1; however with OpenERP values it works fine. In some specific stage configuration, some subtypes could not be tracked precisely. bzr revid: tde@openerp.com-20131023100429-a3vfxi5zkn18v6qq
This commit is contained in:
parent
1322839430
commit
8ce54029cf
|
@ -20,7 +20,7 @@
|
|||
<field name="view_mode">graph,tree,form</field>
|
||||
<field name="view_id" ref="view_crm_opportunity_stage_graph"/>
|
||||
<!-- avoid done / cancelled -->
|
||||
<field name="domain">['&', ('stage_id.closed', '=', False), ('type', '=', 'opportunity')]</field>
|
||||
<field name="domain">['&', ('stage_id.fold', '=', False), ('type', '=', 'opportunity')]</field>
|
||||
<field name="context">{'search_default_Stage':1}</field>
|
||||
</record>
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
|||
<field name="view_mode">graph,tree,form</field>
|
||||
<field name="view_id" ref="view_crm_opportunity_user_stage_graph"/>
|
||||
<!-- avoid cancelled -->
|
||||
<field name="domain">['|', ('stage_id.closed', '=', False), ('stage_id.probability', '=', 100)]</field>
|
||||
<field name="domain">['|', ('stage_id.fold', '=', False), ('stage_id.probability', '=', 100)]</field>
|
||||
<field name="context">{'search_default_user': 1, 'search_default_Stage': 1}</field>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -71,10 +71,6 @@ class crm_case_stage(osv.osv):
|
|||
'fold': fields.boolean('Folded in Kanban View',
|
||||
help='This stage is folded in the kanban view when'
|
||||
'there are no records in that stage to display.'),
|
||||
'closed': fields.boolean('Closing Stage',
|
||||
help='Indicates whether this field is the end of'
|
||||
'the maangement process. This is for example a'
|
||||
'stage considering the lead as won or lost.'),
|
||||
'type': fields.selection([('lead', 'Lead'),
|
||||
('opportunity', 'Opportunity'),
|
||||
('both', 'Both')],
|
||||
|
|
|
@ -71,10 +71,11 @@ class crm_lead(format_address, osv.osv):
|
|||
|
||||
_track = {
|
||||
'stage_id': {
|
||||
'crm.mt_lead_create': lambda self, cr, uid, obj, ctx=None: obj.probability == 0 and obj.stage_id and obj.stage_id.sequence == 1,
|
||||
'crm.mt_lead_stage': lambda self, cr, uid, obj, ctx=None: (obj.stage_id and obj.stage_id.sequence != 1) and obj.probability < 100,
|
||||
# this is only an heuristics; depending on your particular stage configuration it may not match all 'new' stages
|
||||
'crm.mt_lead_create': lambda self, cr, uid, obj, ctx=None: obj.probability == 0 and obj.stage_id and obj.stage_id.sequence <= 1,
|
||||
'crm.mt_lead_stage': lambda self, cr, uid, obj, ctx=None: (obj.stage_id and obj.stage_id.sequence > 1) and obj.probability < 100,
|
||||
'crm.mt_lead_won': lambda self, cr, uid, obj, ctx=None: obj.probability == 100 and obj.stage_id and obj.stage_id.on_change,
|
||||
'crm.mt_lead_lost': lambda self, cr, uid, obj, ctx=None: obj.probability == 0 and obj.stage_id and obj.stage_id.sequence != 1,
|
||||
'crm.mt_lead_lost': lambda self, cr, uid, obj, ctx=None: obj.probability == 0 and obj.stage_id and obj.stage_id.sequence > 1,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -92,7 +93,7 @@ class crm_lead(format_address, osv.osv):
|
|||
def _get_default_stage_id(self, cr, uid, context=None):
|
||||
""" Gives default stage_id """
|
||||
section_id = self._get_default_section_id(cr, uid, context=context)
|
||||
return self.stage_find(cr, uid, [], section_id, [('sequence', '=', '1')], context=context)
|
||||
return self.stage_find(cr, uid, [], section_id, [('fold', '=', False)], context=context)
|
||||
|
||||
def _resolve_section_id_from_context(self, cr, uid, context=None):
|
||||
""" Returns ID of section based on the value of 'section_id'
|
||||
|
@ -381,7 +382,7 @@ class crm_lead(format_address, osv.osv):
|
|||
# AND with the domain in parameter
|
||||
search_domain += list(domain)
|
||||
# perform search, return the first found
|
||||
stage_ids = self.pool.get('crm.case.stage').search(cr, uid, search_domain, order=order, context=context)
|
||||
stage_ids = self.pool.get('crm.case.stage').search(cr, uid, search_domain, order=order, limit=1, context=context)
|
||||
if stage_ids:
|
||||
return stage_ids[0]
|
||||
return False
|
||||
|
@ -391,7 +392,7 @@ class crm_lead(format_address, osv.osv):
|
|||
:deprecated: this method will be removed in OpenERP v8.
|
||||
"""
|
||||
for lead in self.browse(cr, uid, ids):
|
||||
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 0.0), ('on_change', '=', True), ('sequence', '>', 1)], context=context)
|
||||
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 0.0), ('fold', '=', True), ('sequence', '>', 1)], context=context)
|
||||
if stage_id:
|
||||
return self.write(cr, uid, [lead.id], {'stage_id': stage_id}, context=context)
|
||||
else:
|
||||
|
@ -405,7 +406,7 @@ class crm_lead(format_address, osv.osv):
|
|||
:deprecated: this method will be removed in OpenERP v8.
|
||||
"""
|
||||
for lead in self.browse(cr, uid, ids):
|
||||
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 100.0), ('on_change', '=', True), ('sequence', '>', 1)], context=context)
|
||||
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 100.0), ('fold', '=', True), ('sequence', '>', 1)], context=context)
|
||||
if stage_id:
|
||||
return self.write(cr, uid, [lead.id], {'stage_id': stage_id}, context=context)
|
||||
else:
|
||||
|
@ -620,7 +621,7 @@ class crm_lead(format_address, osv.osv):
|
|||
# An Opportunity always has higher confidence level than a lead, unless its stage probability is 0.0
|
||||
for opportunity in opportunities:
|
||||
sequence = -1
|
||||
if opportunity.stage_id and (opportunity.stage_id.probability != 0 or opportunity.stage_id.sequence == 1):
|
||||
if opportunity.stage_id and not opportunity.stage_id.fold:
|
||||
sequence = opportunity.stage_id.sequence
|
||||
sequenced_opps.append(((int(sequence != -1 and opportunity.type == 'opportunity'), sequence, -opportunity.id), opportunity))
|
||||
|
||||
|
@ -681,7 +682,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, [('sequence', '=', '1'), ('type', 'in', ('opportunity','both'))], context=context)
|
||||
val['stage_id'] = self.stage_find(cr, uid, [lead], section_id, [('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):
|
||||
|
@ -691,7 +692,7 @@ class crm_lead(format_address, osv.osv):
|
|||
customer = partner.browse(cr, uid, partner_id, context=context)
|
||||
for lead in self.browse(cr, uid, ids, context=context):
|
||||
# TDE: was if lead.state in ('done', 'cancel'):
|
||||
if (lead.probability == '100') or (lead.probability == '0' and lead.stage_id.sequence != '1'):
|
||||
if lead.probability == 100 or (lead.probability == 0 and lead.stage_id.fold):
|
||||
continue
|
||||
vals = self._convert_opportunity_data(cr, uid, lead, customer, section_id, context=context)
|
||||
self.write(cr, uid, [lead.id], vals, context=context)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
<field name="on_change">1</field>
|
||||
<field name="sequence">30</field>
|
||||
<field name="type">lead</field>
|
||||
<field name="closed" eval="True"/>
|
||||
</record>
|
||||
<record model="crm.case.stage" id="stage_lead3">
|
||||
<field name="name">Qualification</field>
|
||||
|
@ -45,11 +44,11 @@
|
|||
<record model="crm.case.stage" id="stage_lead6">
|
||||
<field name="name">Won</field>
|
||||
<field name="case_default">1</field>
|
||||
<field name="fold">1</field>
|
||||
<field name="probability">100</field>
|
||||
<field name="on_change">1</field>
|
||||
<field name="sequence">70</field>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="closed" eval="True"/>
|
||||
</record>
|
||||
<record model="crm.case.stage" id="stage_lead7">
|
||||
<field name="name">Lost</field>
|
||||
|
@ -59,7 +58,6 @@
|
|||
<field name="on_change">1</field>
|
||||
<field name="sequence">80</field>
|
||||
<field name="type">opportunity</field>
|
||||
<field name="closed" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record model="crm.case.section" id="section_sales_department">
|
||||
|
|
|
@ -341,7 +341,7 @@
|
|||
domain="[('section_id.member_ids', 'in', [uid])]" context="{'invisible_section': False}"
|
||||
help="Leads that are assigned to any sales teams I am member of"/>
|
||||
<filter string="Dead" name="dead"
|
||||
domain="[('probability', '=', '0'), ('stage_id.sequence', '!=', 1)]"/>
|
||||
domain="[('probability', '=', '0'), ('stage_id.fold', '=', True)]"/>
|
||||
<separator />
|
||||
<filter string="Available for mass mailing"
|
||||
name='not_opt_out' domain="[('opt_out', '=', False)]"
|
||||
|
@ -552,12 +552,10 @@
|
|||
<field name="stage_id" domain="[]"/>
|
||||
<field name="probability"/>
|
||||
<separator/>
|
||||
<filter string="New" name="new"
|
||||
domain="[('probability', '=', 0), ('stage_id.sequence', '=', 1)]"/>
|
||||
<filter string="Won" name="won"
|
||||
domain="[('probability', '=', 100), ('stage_id.on_change', '=', 1)]"/>
|
||||
domain="[('probability', '=', 100), ('stage_id.fold', '=', True)]"/>
|
||||
<filter string="Lost" name="lost"
|
||||
domain="[('probability', '=', 0), ('stage_id.sequence', '!=', 1)]"/>
|
||||
domain="[('probability', '=', 0), ('stage_id.fold', '=', True)]"/>
|
||||
<filter string="Unassigned" name="unassigned"
|
||||
domain="[('user_id','=', False)]" help="No salesperson"/>
|
||||
<filter string="My Opportunities" name="assigned_to_me"
|
||||
|
|
|
@ -102,7 +102,6 @@
|
|||
</group>
|
||||
<group>
|
||||
<field name="fold"/>
|
||||
<field name="closed"/>
|
||||
<field name="on_change"/>
|
||||
<field name="case_default" groups="base.group_multi_salesteams"/>
|
||||
</group>
|
||||
|
|
Loading…
Reference in New Issue