[FIX] removing Mark Won/Loss, use stages instead
This commit is contained in:
@@ -341,44 +341,6 @@ class crm_lead(format_address, osv.osv):
|
||||
return stage_ids[0]
|
||||
return False
|
||||
|
||||
def case_mark_lost(self, cr, uid, ids, context=None):
|
||||
""" Mark the case as lost: state=cancel and probability=0
|
||||
"""
|
||||
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), ('on_change', '=', True), ('sequence', '>', 1)], context=context)
|
||||
if stage_id:
|
||||
if stages_leads.get(stage_id):
|
||||
stages_leads[stage_id].append(lead.id)
|
||||
else:
|
||||
stages_leads[stage_id] = [lead.id]
|
||||
else:
|
||||
raise UserError(_('To relieve your sales pipe and group all Lost opportunities, configure one of your sales stage as follow:\n'
|
||||
'probability = 0 %, select "Change Probability Automatically".\n'
|
||||
'Create a specific stage or edit an existing one by editing columns of your opportunity pipe.'))
|
||||
for stage_id, lead_ids in stages_leads.items():
|
||||
self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context)
|
||||
return True
|
||||
|
||||
def case_mark_won(self, cr, uid, ids, context=None):
|
||||
""" Mark the case as won: state=done and probability=100
|
||||
"""
|
||||
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), ('on_change', '=', True)], context=context)
|
||||
if stage_id:
|
||||
if stages_leads.get(stage_id):
|
||||
stages_leads[stage_id].append(lead.id)
|
||||
else:
|
||||
stages_leads[stage_id] = [lead.id]
|
||||
else:
|
||||
raise UserError(_('To relieve your sales pipe and group all Won opportunities, configure one of your sales stage as follow:\n'
|
||||
'probability = 100 % and select "Change Probability Automatically".\n'
|
||||
'Create a specific stage or edit an existing one by editing columns of your opportunity pipe.'))
|
||||
for stage_id, lead_ids in stages_leads.items():
|
||||
self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context)
|
||||
return True
|
||||
|
||||
def log_next_activity_1(self, cr, uid, ids, context=None):
|
||||
return self.log_next_activity_done(cr, uid, ids, next_activity_name='activity_1_id', context=context)
|
||||
|
||||
|
||||
@@ -380,8 +380,6 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Opportunities">
|
||||
<header>
|
||||
<button name="case_mark_won" string="Mark Won" attrs="{'invisible': [('probability', '=', 100)]}" type="object" class="oe_highlight"/>
|
||||
<button name="case_mark_lost" string="Mark Lost" attrs="{'invisible': [('probability', '=', 100)]}" type="object" class="oe_highlight"/>
|
||||
<field name="stage_id" widget="statusbar" clickable="True"
|
||||
options="{'fold_field': 'fold'}"
|
||||
domain="['&', ('team_ids', '=', team_id), '|', ('type', '=', type), ('type', '=', 'both')]"/>
|
||||
@@ -639,22 +637,5 @@
|
||||
<field name="ref_ir_act_window" ref="crm.action_lead_mass_mail"/>
|
||||
</record>
|
||||
|
||||
<record id="action_mark_as_lost" model="ir.actions.server">
|
||||
<field name="name">Mark As Lost</field>
|
||||
<field name="model_id" ref="model_crm_lead"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">
|
||||
if context.get('active_model') == 'crm.lead' and context.get('active_ids'):
|
||||
self.case_mark_lost(cr, uid, context['active_ids'], context=context)
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="ir_mark_as_lost" model="ir.values">
|
||||
<field eval="'client_action_multi'" name="key2"/>
|
||||
<field eval="'crm.lead'" name="model"/>
|
||||
<field name="name">Mark As Lost</field>
|
||||
<field eval="'ir.actions.server,%d'%action_mark_as_lost" name="value"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -30,14 +30,3 @@
|
||||
assert stage_id == stage['id'], "Default stage of opportunity is incorrect!"
|
||||
-
|
||||
Now I change the stage of opportunity to won.
|
||||
-
|
||||
!python {model: crm.lead}: |
|
||||
self.case_mark_won(cr, uid, [ref("test_crm_lead_new")])
|
||||
-
|
||||
I check statge of opp should won, after change stage.
|
||||
-
|
||||
!python {model: crm.lead}: |
|
||||
opp = self.browse(cr, uid, ref('test_crm_lead_new'))
|
||||
stage_id = self.stage_find(cr, uid , [opp], opp.team_id.id or False,[('probability','=',100.0)], context)
|
||||
assert stage_id == opp.stage_id.id, "Stage of opportunity is incorrect!"
|
||||
|
||||
|
||||
@@ -63,19 +63,6 @@
|
||||
assert opp.name == "Interest in Your New Software", "Opportunity name not correct"
|
||||
assert opp.type == 'opportunity', 'Lead is not converted to opportunity!'
|
||||
assert opp.stage_id.id == ref("stage_lead1"), 'Stage of probability is incorrect!'
|
||||
-
|
||||
I loose the second opportunity
|
||||
-
|
||||
!python {model: crm.lead}: |
|
||||
self.case_mark_lost(cr, uid, [ref("crm_case_2")])
|
||||
-
|
||||
I check details of the opportunity after the loose
|
||||
-
|
||||
!python {model: crm.lead}: |
|
||||
lead = self.browse(cr, uid, ref('crm_case_2'))
|
||||
assert lead.stage_id.id == ref('crm.stage_lead7'), "Opportunity stage should be 'Lost'."
|
||||
assert lead.stage_id.sequence != 1 and lead.stage_id.probability == 0.0, "Lost opportunity is not in 'cancel' state!"
|
||||
assert lead.probability == 0.0, "Revenue probability should be 0.0!"
|
||||
-
|
||||
I confirm review needs meeting.
|
||||
-
|
||||
|
||||
Reference in New Issue
Block a user