diff options
| author | Jaysinh Shukla <jsh@openerp.com> | 2015-02-04 11:25:28 +0530 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2015-02-25 10:20:44 +0100 |
| commit | e5875acc6aa19ca0a41ea1b4be9081bfd674005e (patch) | |
| tree | bf065c31e22db4a229807ef2806bb7af4c0a3015 | |
| parent | d4e9640e3428219c37115a320b4ec1e9cba2c169 (diff) | |
[IMP] crm: change heuristic for lost / won stages from
being fold-based to on_change based. Interesting stages have the on_change
field set to true to update the lead / opportunity. Having it folded or not
is more a matter of display than logic.
| -rw-r--r-- | addons/crm/crm.py | 3 | ||||
| -rw-r--r-- | addons/crm/crm_lead.py | 18 | ||||
| -rw-r--r-- | addons/crm/crm_lead_data.xml | 2 | ||||
| -rw-r--r-- | addons/crm/crm_view.xml | 10 |
4 files changed, 17 insertions, 16 deletions
diff --git a/addons/crm/crm.py b/addons/crm/crm.py index d4758d969fa..0c5d0f1e5ae 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -63,8 +63,7 @@ class crm_stage(osv.Model): _defaults = { 'sequence': 1, - 'probability': 0.0, - 'on_change': True, + 'probability': 1.0, 'fold': False, 'type': 'both', 'case_default': True, diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 42dfc8103cf..70bdb498865 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -300,8 +300,8 @@ class crm_lead(format_address, osv.osv): if not stage.on_change: return {'value': {}} vals = {'probability': stage.probability} - if stage.probability >= 100 or (stage.probability == 0 and stage.sequence > 1): - vals['date_closed'] = fields.datetime.now() + if stage.on_change and (stage.probability >= 100 or (stage.probability == 0 and stage.sequence > 1)): + vals['date_closed'] = fields.datetime.now() return {'value': vals} def on_change_partner_id(self, cr, uid, ids, partner_id, context=None): @@ -384,7 +384,7 @@ class crm_lead(format_address, osv.osv): """ stages_leads = {} for lead in self.browse(cr, uid, ids, context=context): - stage_id = self.stage_find(cr, uid, [lead], lead.team_id.id or False, [('probability', '=', 0.0), ('fold', '=', True), ('sequence', '>', 1)], context=context) + stage_id = self.stage_find(cr, uid, [lead], lead.team_id.id or False, [('probability', '=', 0.0), ('on_change', '=', True), ('sequence', '>', 1)], context=context) if stage_id: if stages_leads.get(stage_id): stages_leads[stage_id].append(lead.id) @@ -403,7 +403,7 @@ class crm_lead(format_address, osv.osv): """ stages_leads = {} for lead in self.browse(cr, uid, ids, context=context): - stage_id = self.stage_find(cr, uid, [lead], lead.team_id.id or False, [('probability', '=', 100.0), ('fold', '=', True)], context=context) + stage_id = self.stage_find(cr, uid, [lead], lead.team_id.id or False, [('probability', '=', 100.0), ('on_change', '=', True)], context=context) if stage_id: if stages_leads.get(stage_id): stages_leads[stage_id].append(lead.id) @@ -603,7 +603,7 @@ class crm_lead(format_address, osv.osv): """ Search for opportunities that have the same partner and that arent done or cancelled """ - final_stage_domain = [('stage_id.probability', '<', 100), '|', ('stage_id.probability', '>', 0), ('stage_id.sequence', '<=', 1)] + final_stage_domain = ['|', '|', ('stage_id.on_change', '=', False), ('stage_id.probability', 'not in', [0, 100]), ('stage_id.sequence', '<=', 1)] partner_match_domain = [] for email in set(email_split(email) + [email]): partner_match_domain.append(('email_from', '=ilike', email)) @@ -645,7 +645,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 not opportunity.stage_id.fold: + if opportunity.stage_id and opportunity.stage_id.on_change: sequence = opportunity.stage_id.sequence sequenced_opps.append(((int(sequence != -1 and opportunity.type == 'opportunity'), sequence, -opportunity.id), opportunity)) @@ -714,7 +714,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.fold): + if (lead.probability == 100 or lead.probability == 0) and lead.stage_id.on_change and lead.stage_id.sequence > 1: continue vals = self._convert_opportunity_data(cr, uid, lead, customer, team_id, context=context) self.write(cr, uid, [lead.id], vals, context=context) @@ -971,9 +971,9 @@ class crm_lead(format_address, osv.osv): def _track_subtype(self, cr, uid, ids, init_values, context=None): record = self.browse(cr, uid, ids[0], context=context) - if 'stage_id' in init_values and record.probability == 100 and record.stage_id and record.stage_id.fold: + if 'stage_id' in init_values and record.probability == 100 and record.stage_id and record.stage_id.on_change: return 'crm.mt_lead_won' - elif 'stage_id' in init_values and record.probability == 0 and record.stage_id and record.stage_id.fold and record.stage_id.sequence > 1: + elif 'stage_id' in init_values and record.probability == 0 and record.stage_id and record.stage_id.on_change and record.stage_id.sequence > 1: return 'crm.mt_lead_lost' elif 'stage_id' in init_values and record.probability == 0 and record.stage_id and record.stage_id.sequence <= 1: return 'crm.mt_lead_create' diff --git a/addons/crm/crm_lead_data.xml b/addons/crm/crm_lead_data.xml index e9ab6358f86..fbee866b238 100644 --- a/addons/crm/crm_lead_data.xml +++ b/addons/crm/crm_lead_data.xml @@ -32,6 +32,7 @@ <field name="name">Proposition</field> <field name="case_default">1</field> <field name="probability">40</field> + <field name="on_change">1</field> <field name="sequence">50</field> <field name="type">opportunity</field> </record> @@ -39,6 +40,7 @@ <field name="name">Negotiation</field> <field name="case_default">1</field> <field name="probability">60</field> + <field name="on_change">1</field> <field name="sequence">60</field> <field name="type">opportunity</field> </record> diff --git a/addons/crm/crm_view.xml b/addons/crm/crm_view.xml index ce4c22e773b..5445259af36 100644 --- a/addons/crm/crm_view.xml +++ b/addons/crm/crm_view.xml @@ -79,19 +79,19 @@ <field name="name"/> <field name="sequence"/> <field name="type"/> - <label for="probability" /> - <div> + <field name="on_change"/> + <label for="probability" attrs="{'invisible': [('on_change', '=', False)]}"/> + <div attrs="{'invisible': [('on_change', '=', False)]}"> <field name="probability"/> <p class="text-muted"> - A stage will be considered as 'Won' if the probability is 100% and it is folded in Kanban View.<br/> - A stage will be considered as 'Lost (Dead)' if the probability is 0% and it is folded in Kanban View. + A stage will be considered as 'Won' if the probability is 100% and if 'Change Probability Automatically' is true. The sequence should be greater than 1.<br/> + A stage will be considered as 'Lost' or 'Dead' if the probability is 0% and if 'Change Probability Automatically' is true. The sequence should be greater than 1. </p> </div> <field name="case_default" groups="base.group_multi_salesteams"/> </group> <group> <field name="fold"/> - <field name="on_change"/> <field name="legend_priority"/> </group> </group> |
