Debian Codegraph @

addons/survey_crm/models/templates/survey_survey.py

raw
1 from odoo import api, models, _
2
3
4 class SurveySurvey(models.Model):
5 """ Add the new 'Lead Qualification' survey template to the templates that can be selected in the helper screen. """
6 _inherit = 'survey.survey'
7
8 @api.model
9 def get_survey_templates_data(self):
10 return super().get_survey_templates_data() | {
11 'lead_qualification': {
12 'description': _('Create leads when key answers are chosen'),
13 'icon': '/survey_crm/static/src/img/survey_sample_lead_qualification.svg',
14 'template_key': 'lead_qualification',
15 'title': _('Lead Qualification'),
16 },
17 }
18
19 def _get_survey_template_values(self, template_key):
20 if template_key == 'lead_qualification':
21 return self._prepare_lead_qualification_template_values()
22 return super()._get_survey_template_values(template_key)
23
24 @api.model
25 def _prepare_lead_qualification_template_values(self):
26 return {
27 'survey_type': 'survey',
28 'title': _('Getting to know you'),
29 'description_done': _('Thanks for answering!'),
30 'progression_mode': 'number',
31 'questions_layout': 'page_per_question',
32 'question_and_page_ids': [
33 (0, 0, { # survey.question
34 'title': _('Let\'s start with a basic question. What\'s your email address?'),
35 'question_type': 'char_box',
36 'constr_mandatory': True,
37 'validation_email': True,
38 'save_as_email': True,
39 }),
40 (0, 0, { # survey.question
41 'title': _('What is the size of your company?'),
42 'question_type': 'simple_choice',
43 'constr_mandatory': True,
44 'suggested_answer_ids': [
45 (0, 0, { # survey.question.answer
46 'value': _('1-10 employees'),
47 }),
48 (0, 0, { # survey.question.answer
49 'value': _('11-100 employees'),
50 'generate_lead': True
51 }),
52 (0, 0, { # survey.question.answer
53 'value': _('100+ employees'),
54 })
55 ]
56 }),
57 (0, 0, { # survey.question
58 'title': _('Which of the following best describes your main goal?'),
59 'question_type': 'simple_choice',
60 'constr_mandatory': True,
61 'suggested_answer_ids': [
62 (0, 0, { # survey.question.answer
63 'value': _('Improving efficiency'),
64 'generate_lead': True
65 }),
66 (0, 0, { # survey.question.answer
67 'value': _('Reducing costs'),
68 }),
69 (0, 0, { # survey.question.answer
70 'value': _('Expanding sales'),
71 'generate_lead': True
72 })
73 ]
74 }),
75 (0, 0, { # survey.question
76 'title': _('Who will make the final decision on this purchase?'),
77 'question_type': 'simple_choice',
78 'constr_mandatory': True,
79 'suggested_answer_ids': [
80 (0, 0, { # survey.question.answer
81 'value': _('Me'),
82 'generate_lead': True
83 }),
84 (0, 0, { # survey.question.answer
85 'value': _('My Manager/Executive'),
86 'generate_lead': True
87 }),
88 (0, 0, { # survey.question.answer
89 'value': _('A team/committee'),
90 })
91 ]
92 }),
93 ]
94 }