diff --git a/addons/base_status/base_stage.py b/addons/base_status/base_stage.py index feb3fe59b75..418c927fc0b 100644 --- a/addons/base_status/base_stage.py +++ b/addons/base_status/base_stage.py @@ -199,3 +199,29 @@ class base_stage(object): raise osv.except_osv(_('Error!'), _("You are already at the top level of your sales-team category.\nTherefore you cannot escalate furthermore.")) self.write(cr, uid, [case.id], data, context=context) return True + + def case_set(self, cr, uid, ids, new_state_name=None, values_to_update=None, new_stage_id=None, context=None): + """ Generic method for setting case. This methods wraps the update + of the record. + + :params new_state_name: the new state of the record; this method + will call ``stage_set_with_state_name`` + that will find the stage matching the + new state, using the ``stage_find`` method. + :params new_stage_id: alternatively, you may directly give the + new stage of the record + :params state_name: the new value of the state, such as + 'draft' or 'close'. + :params update_values: values that will be added with the state + update when writing values to the record. + """ + cases = self.browse(cr, uid, ids, context=context) + # 1. update the stage + if new_state_name: + self.stage_set_with_state_name(cr, uid, cases, new_state_name, context=context) + elif not (new_stage_id is None): + self.stage_set(cr, uid, ids, new_stage_id, context=context) + # 2. update values + if values_to_update: + self.write(cr, uid, ids, values_to_update, context=context) + return True diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index aa989f3a393..ab948cc6035 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -413,10 +413,9 @@ class crm_lead(base_stage, format_address, osv.osv): if stage_id: self.case_set(cr, uid, [lead.id], new_stage_id=stage_id, context=context) else: - raise self.pool.get('res.config.settings').get_config_warning(cr, - _("To relieve your sales pipe and group all Lost opportunities, configure one of your sales stage as follow:\n" - "probability = 0, sequence != 1 and on_change = True.\n" - "You can create a specific column or edit an existing one from the menu %(menu:crm.menu_crm_case_section_act)s"), context=context) + raise osv.except_osv(_('Warning!'), _('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.')) return True def case_mark_won(self, cr, uid, ids, context=None): @@ -426,10 +425,9 @@ class crm_lead(base_stage, format_address, osv.osv): if stage_id: self.case_set(cr, uid, [lead.id], new_stage_id=stage_id, context=context) else: - raise self.pool.get('res.config.settings').get_config_warning(cr, - _("To relieve your sales pipe and group all Won opportunities, configure one of your sales stage as follow:\n" - "probability = 100 and on_change = True.\n" - "You can create a specific column or edit an existing one from the menu %(menu:crm.menu_crm_case_section_act)s"), context=context) + raise osv.except_osv(_('Warning!'), _('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.')) return True def set_priority(self, cr, uid, ids, priority): diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index fa78284b15e..20097b2adee 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -328,7 +328,7 @@ - + @@ -378,7 +378,7 @@