File: survey.py

package info (click to toggle)
oca-core 11.0.20180730-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 509,684 kB
  • sloc: xml: 258,806; python: 164,081; sql: 217; sh: 92; makefile: 16
file content (27 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo 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