Files
odoo_source/addons/website_event_crm_questions/models/event_registration.py
T
dht-odoo 586ae4bcc4 [IMP] crm: improves description field type from text to html
Replace text fields to html fields as we have our own 'OdooEditor'.
Indeed, it gives more options to users in the way they format their
content without weighting too much on the UI
(tools appear on demand and not by default).

Models -> Fields

1) crm.lead -> description
2) event.event -> note

Task Id: 2499504

X-original-commit: 524e2f089a611d897b98d86001bda5d17263db66
2021-06-07 05:24:08 +00:00

27 lines
1.2 KiB
Python

# -*- 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, 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(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 = "<br/>".join([" %s" % line for line in answer_value.split('\n')])
answer_descriptions.append(" - %s<br/>%s" % (answer.question_id.title, answer_value))
return "%s%s<br/>%s" % (reg_description, _("Questions"), '<br/>'.join(answer_descriptions))
def _get_lead_description_fields(self):
res = super(EventRegistration, self)._get_lead_description_fields()
res.append('registration_answer_ids')
return res