diff --git a/addons/crm/models/crm_lead.py b/addons/crm/models/crm_lead.py index a68cc5ae48d..b6829a25708 100644 --- a/addons/crm/models/crm_lead.py +++ b/addons/crm/models/crm_lead.py @@ -66,7 +66,7 @@ class Lead(models.Model): name = fields.Char('Opportunity', required=True, index=True) partner_id = fields.Many2one('res.partner', string='Customer', track_visibility='onchange', track_sequence=1, index=True, help="Linked partner (optional). Usually created when converting the lead.") - active = fields.Boolean('Active', default=True) + active = fields.Boolean('Active', default=True, track_visibility=True) date_action_last = fields.Datetime('Last Action', readonly=True) email_from = fields.Char('Email', help="Email address of the contact", track_visibility='onchange', track_sequence=4, index=True) website = fields.Char('Website', index=True, help="Website of the contact") @@ -354,14 +354,6 @@ class Lead(models.Model): """ Lost semantic: probability = 0, active = False """ return self.write({'probability': 0, 'active': False}) - @api.multi - def action_set_active(self): - return self.write({'active': True}) - - @api.multi - def action_set_unactive(self): - return self.write({'active': False}) - @api.multi def action_set_won(self): """ Won semantic: probability = 100 (active untouched) """ @@ -459,6 +451,14 @@ class Lead(models.Model): 'context': {'default_type': 'opportunity'} } + def toggle_active(self): + """ When re-activating leads and opportunities set their probability + to the default stage one. """ + res = super(Lead, self).toggle_active() + for lead in self.filtered(lambda lead: lead.active and lead.stage_id.probability): + lead.probability = lead.stage_id.probability + return res + # ---------------------------------------- # Business Methods # ---------------------------------------- diff --git a/addons/crm/report/crm_opportunity_report_views.xml b/addons/crm/report/crm_opportunity_report_views.xml index 07329f850bb..d263b5bc8b0 100644 --- a/addons/crm/report/crm_opportunity_report_views.xml +++ b/addons/crm/report/crm_opportunity_report_views.xml @@ -75,9 +75,6 @@ - - - diff --git a/addons/crm/views/crm_lead_views.xml b/addons/crm/views/crm_lead_views.xml index 5813b5a7378..f4a5ba6ca19 100644 --- a/addons/crm/views/crm_lead_views.xml +++ b/addons/crm/views/crm_lead_views.xml @@ -45,14 +45,21 @@
+
-
-
Won
+
Lost
+
Won
@@ -400,7 +406,7 @@ + domain="['&', ('probability', '=', 0), ('active', '=', False)]"/> @@ -439,12 +445,17 @@ type="action" class="oe_highlight" context="{'default_lead_id': active_id}" attrs="{'invisible': [('active', '=', False),('probability', '<', 100)]}"/> + - -
Lost
-
Won
+
Lost
+
Won