flectra/addons/survey_crm/models/survey.py

28 lines
1.1 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2018-01-16 11:34:37 +01:00
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
2018-01-16 11:34:37 +01:00
from flectra import api, models
class SurveyComposeMessage(models.TransientModel):
_inherit = 'survey.mail.compose.message'
@api.model
def default_get(self, fields):
result = super(SurveyComposeMessage, self).default_get(fields)
if self._context.get('active_model') == 'crm.lead' and self._context.get('active_ids'):
partner_ids = []
emails_list = []
for lead in self.env['crm.lead'].browse(self._context.get('active_ids')):
if lead.partner_id:
partner_ids.append(lead.partner_id.id)
else:
email = lead.contact_name and "%s <%s>" % (lead.contact_name, lead.email_from or "") or lead.email_from or None
if email and email not in emails_list:
emails_list.append(email)
multi_email = "\n".join(emails_list)
result.update({'partner_ids': list(set(partner_ids)), 'multi_email': multi_email})
return result