[FIX] crm: write a value to date_closed field as well if change directly the stage instead of using buttons (which will probably be removed later)
bzr revid: mat@openerp.com-20140311150446-0atbc6esymjyv69e
This commit is contained in:
parent
8db1b77757
commit
5041f63b35
|
@ -926,11 +926,14 @@ class crm_lead(base_stage, format_address, osv.osv):
|
|||
return res
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
if vals.get('stage_id') and not vals.get('probability'):
|
||||
# change probability of lead(s) if required by stage
|
||||
if vals.get('stage_id'):
|
||||
stage = self.pool.get('crm.case.stage').browse(cr, uid, vals['stage_id'], context=context)
|
||||
if stage.on_change:
|
||||
if not vals.get('probability') and stage.on_change:
|
||||
# change probability of lead(s) if required by stage
|
||||
vals['probability'] = stage.probability
|
||||
# set closed date when won or lost
|
||||
if not vals.get('date_closed') and (vals.get('probability', 0) >= 100 or stage.state == 'canceled'):
|
||||
vals['date_closed'] = fields.datetime.now()
|
||||
return super(crm_lead, self).write(cr, uid, ids, vals, context=context)
|
||||
|
||||
def copy(self, cr, uid, id, default=None, context=None):
|
||||
|
|
Loading…
Reference in New Issue