[IMP] crm: Historize changes on Stage for Leads and Opportunities.
bzr revid: uco@tinyerp.com-20101101094617-oujei764tfi1hpo5
This commit is contained in:
parent
535205d836
commit
37be991751
|
@ -286,11 +286,19 @@ class crm_lead(crm_case, osv.osv):
|
||||||
stage = super(crm_lead, self).stage_next(cr, uid, ids, context)
|
stage = super(crm_lead, self).stage_next(cr, uid, ids, context)
|
||||||
if stage:
|
if stage:
|
||||||
stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, stage, context=context)
|
stage_obj = self.pool.get('crm.case.stage').browse(cr, uid, stage, context=context)
|
||||||
|
self.onchange_stage_id(cr, uid, ids, stage)
|
||||||
if stage_obj.on_change:
|
if stage_obj.on_change:
|
||||||
data = {'probability': stage_obj.probability}
|
data = {'probability': stage_obj.probability}
|
||||||
self.write(cr, uid, ids, data)
|
self.write(cr, uid, ids, data)
|
||||||
return stage
|
return stage
|
||||||
|
|
||||||
|
def stage_previous(self, cr, uid, ids, context=None):
|
||||||
|
stage = super(crm_lead, self).stage_previous(cr, uid, ids, context)
|
||||||
|
if stage:
|
||||||
|
for case in self.browse(cr, uid, ids):
|
||||||
|
self.onchange_stage_id(cr, uid, [case.id], case.stage_id.id)
|
||||||
|
return stage
|
||||||
|
|
||||||
def message_new(self, cr, uid, msg, context):
|
def message_new(self, cr, uid, msg, context):
|
||||||
"""
|
"""
|
||||||
Automatically calls when new email message arrives
|
Automatically calls when new email message arrives
|
||||||
|
|
|
@ -57,7 +57,8 @@
|
||||||
<newline />
|
<newline />
|
||||||
<field name="section_id" widget="selection" />
|
<field name="section_id" widget="selection" />
|
||||||
<field name="user_id" />
|
<field name="user_id" />
|
||||||
<field name="stage_id" domain="[('object_id.model', '=', 'crm.lead'), ('section_ids', '=', section_id)]"/>
|
<field name="stage_id" domain="[('object_id.model', '=', 'crm.lead'), ('section_ids', '=', section_id)]"
|
||||||
|
on_change="onchange_stage_id(stage_id)"/>
|
||||||
<group col="2" colspan="1">
|
<group col="2" colspan="1">
|
||||||
<button name="stage_previous" string=""
|
<button name="stage_previous" string=""
|
||||||
states="open,pending,draft" type="object"
|
states="open,pending,draft" type="object"
|
||||||
|
|
|
@ -142,11 +142,18 @@ class crm_opportunity(osv.osv):
|
||||||
@param uid: the current user’s ID for security checks,
|
@param uid: the current user’s ID for security checks,
|
||||||
@param ids: List of stage’s IDs
|
@param ids: List of stage’s IDs
|
||||||
@stage_id: change state id on run time """
|
@stage_id: change state id on run time """
|
||||||
|
|
||||||
if not stage_id:
|
if not stage_id:
|
||||||
return {'value':{}}
|
return {'value':{}}
|
||||||
|
|
||||||
stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context)
|
stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context)
|
||||||
|
self.history(cr, uid, ids, _('Stage'), details=stage.name)
|
||||||
|
for case in self.browse(cr, uid, ids):
|
||||||
|
if case.type == 'lead':
|
||||||
|
message = _("The stage of lead '%s' has been changed to '%s'.") % (case.name, case.stage_id.name)
|
||||||
|
elif case.type == 'opportunity':
|
||||||
|
message = _("The stage of opportunity '%s' has been changed to '%s'.") % (case.name, case.stage_id.name)
|
||||||
|
self.log(cr, uid, case.id, message)
|
||||||
|
|
||||||
if not stage.on_change:
|
if not stage.on_change:
|
||||||
return {'value':{}}
|
return {'value':{}}
|
||||||
return {'value':{'probability': stage.probability}}
|
return {'value':{'probability': stage.probability}}
|
||||||
|
|
|
@ -250,6 +250,8 @@ class mailgate_message(osv.osv):
|
||||||
elif message.name == _('Note'):
|
elif message.name == _('Note'):
|
||||||
msg_txt = (message.user_id.name or '/') + _(' added note on ') + format_date_tz(message.date, tz) + ':\n\t'
|
msg_txt = (message.user_id.name or '/') + _(' added note on ') + format_date_tz(message.date, tz) + ':\n\t'
|
||||||
msg_txt += self.truncate_data(cr, uid, message.description, context=context)
|
msg_txt += self.truncate_data(cr, uid, message.description, context=context)
|
||||||
|
elif message.name == _('Stage'):
|
||||||
|
msg_txt += _("Changed Stage to: ") + message.description
|
||||||
else:
|
else:
|
||||||
msg_txt += _("Changed Status to: ") + message.name
|
msg_txt += _("Changed Status to: ") + message.name
|
||||||
result[message.id] = msg_txt
|
result[message.id] = msg_txt
|
||||||
|
|
Loading…
Reference in New Issue