[IMP] crm: leads and opportunities - buttons, stages and probabilities stuff

bzr revid: qdp-launchpad@tinyerp.com-20100712221032-9lcpurgrmo2u4zla
This commit is contained in:
qdp-launchpad@tinyerp.com
2010-07-13 03:40:32 +05:30
parent 664ff3b99b
commit e19eb5d3c0
3 changed files with 51 additions and 13 deletions
+8 -4
View File
@@ -124,7 +124,7 @@ class crm_case(object):
stage_pool = self.pool.get('crm.case.stage')
for case in self.browse(cr, uid, ids, context):
if section in s:
st = case.stage_id.id or False
st = not context.get('force_domain', False) and case.stage_id.id or False
if st in s[section]:
data = {'stage_id': s[section][st]}
stage = s[section][st]
@@ -141,8 +141,12 @@ class crm_case(object):
if not context:
context = {}
stage_obj = self.pool.get('crm.case.stage')
sid = stage_obj.search(cr, uid, \
[('object_id.model', '=', self._name)], context=context)
tmp = self.read(cr, uid, ids, ['section_id'], context)[0]['section_id']
section_id = tmp and tmp[0] or False
domain = [('object_id.model', '=', self._name), ('section_id', '=', section_id)]
if 'force_domain' in context and context['force_domain']:
domain += context['force_domain']
sid = stage_obj.search(cr, uid, domain, context=context)
s = {}
previous = {}
section = self._name
@@ -168,7 +172,7 @@ class crm_case(object):
stage_pool = self.pool.get('crm.case.stage')
for case in self.browse(cr, uid, ids, context):
if section in s:
st = case.stage_id.id or False
st = not context.get('force_domain', False) and case.stage_id.id or False
s[section] = dict([(v, k) for (k, v) in s[section].iteritems()])
if st in s[section]:
data = {'stage_id': s[section][st]}
+11 -3
View File
@@ -177,10 +177,18 @@ and users"),
@param ids: List of case's Ids
@param *args: Give Tuple Value
"""
old_state = self.read(cr, uid, ids, ['state'])[0]['state']
res = super(crm_lead, self).case_open(cr, uid, ids, *args)
self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')})
if old_state == 'draft':
stage_id = super(crm_lead, self).stage_next(cr, uid, ids, *args)
if not stage_id:
raise osv.except_osv(_('Warning !'), _('There is no stage defined for this Sale Team.'))
value = self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value']
value.update({'date_open': time.strftime('%Y-%m-%d %H:%M:%S'), 'stage_id': stage_id})
self.write(cr, uid, ids, value)
for (id, name) in self.name_get(cr, uid, ids):
message = _('Lead ') + " '" + name + "' "+ _("is Open.")
message = _('The Lead') + " '" + name + "' "+ _("has been written as Open.")
self.log(cr, uid, id, message)
return res
@@ -195,7 +203,7 @@ and users"),
res = super(crm_lead, self).case_close(cr, uid, ids, args)
self.write(cr, uid, ids, {'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')})
for (id, name) in self.name_get(cr, uid, ids):
message = _('Lead ') + " '" + name + "' "+ _("is Closed.")
message = _('The Lead') + " '" + name + "' "+ _("has been written as Closed.")
self.log(cr, uid, id, message)
return res
+32 -6
View File
@@ -64,9 +64,15 @@ class crm_opportunity(osv.osv):
@param *args: Tuple Value for additional Params
"""
res = super(crm_opportunity, self).case_close(cr, uid, ids, args)
self.write(cr, uid, ids, {'probability' : 100.0, 'date_closed': time.strftime('%Y-%m-%d %H:%M:%S')})
stage_id = super(crm_opportunity, self).stage_next(cr, uid, ids, context={'force_domain': [('probability', '=', 100)]})
if not stage_id:
raise osv.except_osv(_('Warning !'), _('There is no stage for won oppportunities defined for this Sale Team.'))
value = self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value']
value.update({'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), 'stage_id': stage_id})
self.write(cr, uid, ids, value)
for (id, name) in self.name_get(cr, uid, ids):
message = _('Opportunity ') + " '" + name + "' "+ _("is Won.")
message = _('The Opportunity') + " '" + name + "' "+ _("has been written as Won.")
self.log(cr, uid, id, message)
return res
@@ -78,9 +84,16 @@ class crm_opportunity(osv.osv):
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
res = self.write(cr, uid, ids, {'probability' : 0.0, 'state': 'done'})
res = super(crm_opportunity, self).case_close(cr, uid, ids, args)
stage_id = super(crm_opportunity, self).stage_next(cr, uid, ids, context={'force_domain': [('probability', '=', 0)]})
if not stage_id:
raise osv.except_osv(_('Warning !'), _('There is no stage for lost oppportunities defined for this Sale Team.'))
value = self.onchange_stage_id(cr, uid, ids, stage_id, context={})['value']
value.update({'date_closed': time.strftime('%Y-%m-%d %H:%M:%S'), 'stage_id': stage_id})
res = self.write(cr, uid, ids, value)
for (id, name) in self.name_get(cr, uid, ids):
message = _('Opportunity ') + " '" + name + "' "+ _("is Lost.")
message = _('The Opportunity') + " '" + name + "' "+ _("has been written as Lost.")
self.log(cr, uid, id, message)
return res
@@ -95,9 +108,22 @@ class crm_opportunity(osv.osv):
res = super(crm_opportunity, self).case_cancel(cr, uid, ids, args)
self.write(cr, uid, ids, {'probability' : 0.0})
return res
def case_reset(self, cr, uid, ids, *args):
"""Overrides reset as draft in order to set the stage field as empty
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,
@param ids: List of case Ids
@param *args: Tuple Value for additional Params
"""
res = super(crm_opportunity, self).case_reset(cr, uid, ids, *args)
self.write(cr, uid, ids, {'stage_id': False})
return True
def case_open(self, cr, uid, ids, *args):
"""Overrides cancel for crm_case for setting Open Date
"""Overrides open for crm_case for setting Open Date
@param self: The object pointer
@param cr: the current row, from the database cursor,
@param uid: the current user’s ID for security checks,