'phone': partner.phone,
'mobile': partner.mobile,
'fax': partner.fax,
+ 'zip': partner.zip,
}
return {'value': values}
""" Mark the case as lost: state=cancel and probability=0
:deprecated: this method will be removed in OpenERP v8.
"""
- for lead in self.browse(cr, uid, ids):
+ stages_leads = {}
+ for lead in self.browse(cr, uid, ids, context=context):
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 0.0), ('fold', '=', True), ('sequence', '>', 1)], context=context)
if stage_id:
- return self.write(cr, uid, [lead.id], {'stage_id': stage_id}, context=context)
+ if stages_leads.get(stage_id):
+ stages_leads[stage_id].append(lead.id)
+ else:
+ stages_leads[stage_id] = [lead.id]
else:
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.'))
+ for stage_id, lead_ids in stages_leads.items():
+ self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context)
+ return True
def case_mark_won(self, cr, uid, ids, context=None):
""" Mark the case as won: state=done and probability=100
:deprecated: this method will be removed in OpenERP v8.
"""
- for lead in self.browse(cr, uid, ids):
+ stages_leads = {}
+ for lead in self.browse(cr, uid, ids, context=context):
stage_id = self.stage_find(cr, uid, [lead], lead.section_id.id or False, [('probability', '=', 100.0), ('fold', '=', True)], context=context)
if stage_id:
- return self.write(cr, uid, [lead.id], {'stage_id': stage_id}, context=context)
+ if stages_leads.get(stage_id):
+ stages_leads[stage_id].append(lead.id)
+ else:
+ stages_leads[stage_id] = [lead.id]
else:
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.'))
+ for stage_id, lead_ids in stages_leads.items():
+ self.write(cr, uid, lead_ids, {'stage_id': stage_id}, context=context)
+ return True
def case_escalate(self, cr, uid, ids, context=None):
""" Escalates case to parent level """
model_data = self.pool.get('ir.model.data')
phonecall_dict = {}
if not categ_id:
- res_id = model_data._get_id(cr, uid, 'crm', 'categ_phone2')
- if res_id:
+ try:
+ res_id = model_data._get_id(cr, uid, 'crm', 'categ_phone2')
categ_id = model_data.browse(cr, uid, res_id, context=context).res_id
+ except ValueError:
+ pass
for lead in self.browse(cr, uid, ids, context=context):
if not section_id:
section_id = lead.section_id and lead.section_id.id or False
vals.update(onchange_stage_values)
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)
+
# ----------------------------------------
# Mail Gateway
# ----------------------------------------
def schedule_phonecall_send_note(self, cr, uid, ids, phonecall_id, action, context=None):
phonecall = self.pool.get('crm.phonecall').browse(cr, uid, [phonecall_id], context=context)[0]
if action == 'log':
- prefix = 'Logged'
+ message = _('Logged a call for %(date)s. %(description)s')
else:
- prefix = 'Scheduled'
- suffix = ' %s' % phonecall.description
- message = _("%s a call for %s.%s") % (prefix, phonecall.date, suffix)
+ message = _('Scheduled a call for %(date)s. %(description)s')
+ phonecall_date = datetime.strptime(phonecall.date, tools.DEFAULT_SERVER_DATETIME_FORMAT)
+ phonecall_usertime = fields.datetime.context_timestamp(cr, uid, phonecall_date, context=context).strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT)
+ html_time = "<time datetime='%s+00:00'>%s</time>" % (phonecall.date, phonecall_usertime)
+ message = message % dict(date=html_time, description=phonecall.description)
return self.message_post(cr, uid, ids, body=message, context=context)
def log_meeting(self, cr, uid, ids, meeting_subject, meeting_date, duration, context=None):