summaryrefslogtreecommitdiff
path: root/addons/website_event_crm_questions/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/website_event_crm_questions/models
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/website_event_crm_questions/models')
-rw-r--r--addons/website_event_crm_questions/models/__init__.py4
-rw-r--r--addons/website_event_crm_questions/models/event_registration.py26
2 files changed, 30 insertions, 0 deletions
diff --git a/addons/website_event_crm_questions/models/__init__.py b/addons/website_event_crm_questions/models/__init__.py
new file mode 100644
index 00000000..20ce9ac3
--- /dev/null
+++ b/addons/website_event_crm_questions/models/__init__.py
@@ -0,0 +1,4 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from . import event_registration
diff --git a/addons/website_event_crm_questions/models/event_registration.py b/addons/website_event_crm_questions/models/event_registration.py
new file mode 100644
index 00000000..724ced14
--- /dev/null
+++ b/addons/website_event_crm_questions/models/event_registration.py
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from odoo import models, _
+
+
+class EventRegistration(models.Model):
+ _inherit = 'event.registration'
+
+ def _get_lead_description_registration(self, prefix='', line_suffix=''):
+ """Add the questions and answers linked to the registrations into the description of the lead."""
+ reg_description = super(EventRegistration, self)._get_lead_description_registration(prefix=prefix, line_suffix=line_suffix)
+ if not self.registration_answer_ids:
+ return reg_description
+
+ answer_descriptions = []
+ for answer in self.registration_answer_ids:
+ answer_value = answer.value_answer_id.name if answer.question_type == "simple_choice" else answer.value_text_box
+ answer_value = "\n".join([" %s" % line for line in answer_value.split('\n')])
+ answer_descriptions.append(" - %s\n%s" % (answer.question_id.title, answer_value))
+ return "%s\n%s\n%s" % (reg_description, _("Questions"), '\n'.join(answer_descriptions))
+
+ def _get_lead_description_fields(self):
+ res = super(EventRegistration, self)._get_lead_description_fields()
+ res.append('registration_answer_ids')
+ return res