[FIX]crm: duplicating lead/opp duplicated the stage and put to false date_open if it was an opp. Now put stage to 'new' stage and set date_open to today if it is an opp

bzr revid: dle@openerp.com-20131114204550-wavibpj1memdx60c
This commit is contained in:
Denis Ledoux 2013-11-14 21:45:50 +01:00
parent 4b3ab2142d
commit 8711954c1c
1 changed files with 17 additions and 0 deletions

View File

@ -933,6 +933,23 @@ class crm_lead(base_stage, format_address, osv.osv):
vals['probability'] = stage.probability
return super(crm_lead, self).write(cr, uid, ids, vals, context=context)
def copy(self, cr, uid, id, default=None, context=None):
if not default:
default = {}
if not context:
context = {}
lead = self.browse(cr, uid, id, context=context)
local_context = dict(context)
local_context.setdefault('default_type', lead.type)
local_context.setdefault('default_section_id', lead.section_id)
if lead.type == 'opportunity':
default['date_open'] = fields.datetime.now()
else:
default['date_open'] = False
default['date_closed'] = False
default['stage_id'] = self._get_default_stage_id(cr, uid, local_context)
return super(crm_lead, self).copy(cr, uid, id, default, context=context)
def new_mail_send(self, cr, uid, ids, context=None):
'''
This function opens a window to compose an email, with the edi sale template message loaded by default