[IMP] crm: Set lost reason when marking several leads as lost
======= PURPOSE ======= In list view, when handling in mass the opportunities and mark it as lost, it should be possible to set the lost reason. The reason would be the same for all the selected opportunities. ============= SPECIFICATION ============= On clicking of 'Mark as Lost', ask user the lost reason through wizard. and then set that lost reason to all the opportunities selected.
This commit is contained in:
committed by
Yannick Tivisse
parent
7d89d0483e
commit
198a0b8ff6
@@ -670,8 +670,10 @@
|
||||
<field name="model_id" ref="model_crm_lead"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">
|
||||
if env.context.get('active_model') == 'crm.lead' and env.context.get('active_ids'):
|
||||
env['crm.lead'].browse(context['active_ids']).action_set_lost()
|
||||
if context.get('active_model') == 'crm.lead' and context.get('active_ids'):
|
||||
action_values = env.ref('crm.crm_lead_lost_action').read()[0]
|
||||
action_values.update({'context': context})
|
||||
action = action_values
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ class CrmLeadLost(models.TransientModel):
|
||||
_name = 'crm.lead.lost'
|
||||
_description = 'Get Lost Reason'
|
||||
|
||||
lead_id = fields.Many2one('crm.lead', 'Lead', required=True)
|
||||
lost_reason_id = fields.Many2one('crm.lost.reason', 'Lost Reason')
|
||||
|
||||
@api.multi
|
||||
def action_lost_reason_apply(self):
|
||||
self.lead_id.lost_reason = self.lost_reason_id
|
||||
return self.lead_id.action_set_lost()
|
||||
leads = self.env['crm.lead'].browse(self.env.context.get('active_ids'))
|
||||
leads.write({'lost_reason': self.lost_reason_id.id})
|
||||
return leads.action_set_lost()
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
<field name="arch" type="xml">
|
||||
<form string="Lost Reason">
|
||||
<group class="oe_title">
|
||||
<field name="lead_id" invisible="1"/>
|
||||
<field name="lost_reason_id"/>
|
||||
</group>
|
||||
<footer>
|
||||
|
||||
Reference in New Issue
Block a user