[ADD] survey_contact_generation, survey_event_registration_generation
This commit is contained in:
3
survey_event_registration_generation/models/__init__.py
Normal file
3
survey_event_registration_generation/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from . import survey_question
|
||||
from . import survey_user_input
|
||||
from . import survey_user_input_line
|
@@ -0,0 +1,28 @@
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class SurveyQuestion(models.Model):
|
||||
_inherit = 'survey.question'
|
||||
|
||||
question_type = fields.Selection(
|
||||
selection_add=[('event_product', 'Event product'),('event', 'Event')])
|
||||
|
||||
|
||||
event_product_question_id = fields.Many2one(
|
||||
'survey.question', string="Event ticket question", copy=False, compute="_compute_event_product_question_id",
|
||||
store=True, readonly=False, help="If you specify question of event product, only events of selected product will be proposed.",
|
||||
domain="[('survey_id', '=', survey_id), \
|
||||
'&', ('question_type', '=', 'event_product'), \
|
||||
'|', \
|
||||
('sequence', '<', sequence), \
|
||||
'&', ('sequence', '=', sequence), ('id', '<', id)]")
|
||||
|
||||
|
||||
@api.depends('question_type')
|
||||
def _compute_event_product_question_id(self):
|
||||
""" Used as an 'onchange' : Reset the event ticket question if user change question type
|
||||
Avoid CacheMiss : set the value to False if the value is not set yet."""
|
||||
for question in self:
|
||||
if not question.question_type == 'event' or question.triggering_question_id is None:
|
||||
question.triggering_question_id = False
|
||||
|
@@ -0,0 +1,47 @@
|
||||
|
||||
import logging
|
||||
import textwrap
|
||||
import uuid
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tools import float_is_zero
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SurveyUserInput(models.Model):
|
||||
_inherit = 'survey.user_input'
|
||||
|
||||
def save_lines(self, question, answer, comment=None):
|
||||
old_answers = self.env['survey.user_input.line'].search([
|
||||
('user_input_id', '=', self.id),
|
||||
('question_id', '=', question.id)
|
||||
])
|
||||
if question.question_type == 'event_product':
|
||||
self._save_event_product(question, old_answers, answer)
|
||||
elif question.question_type == 'event':
|
||||
self._save_event(question, old_answers, answer)
|
||||
else:
|
||||
return super().save_lines(question, answer, comment)
|
||||
|
||||
|
||||
def _save_event_product(self, question, old_answers, answer):
|
||||
vals = self._get_line_answer_values(question, answer, question.question_type)
|
||||
vals['value_event_product'] = int(vals['value_event_product'])
|
||||
if old_answers:
|
||||
old_answers.write(vals)
|
||||
return old_answers
|
||||
else:
|
||||
return self.env['survey.user_input.line'].create(vals)
|
||||
|
||||
def _save_event(self, question, old_answers, answer):
|
||||
vals = self._get_line_answer_values(question, answer, question.question_type)
|
||||
vals['value_event'] = int(vals['value_event'])
|
||||
if old_answers:
|
||||
old_answers.write(vals)
|
||||
return old_answers
|
||||
else:
|
||||
return self.env['survey.user_input.line'].create(vals)
|
@@ -0,0 +1,28 @@
|
||||
import logging
|
||||
import textwrap
|
||||
import uuid
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tools import float_is_zero
|
||||
|
||||
|
||||
class SurveyUserInputLine(models.Model):
|
||||
_inherit = 'survey.user_input.line'
|
||||
|
||||
answer_type = fields.Selection(
|
||||
selection_add=[('event_product', 'Event product'),('event', 'Event')])
|
||||
|
||||
value_event = fields.Many2one('event.event', string="Event")
|
||||
value_event_product = fields.Many2one('product.product', string="Event product")
|
||||
|
||||
def _compute_display_name(self):
|
||||
super()._compute_display_name()
|
||||
for line in self:
|
||||
if line.answer_type == 'event_product':
|
||||
line.display_name = line.value_event_product.name
|
||||
elif line.answer_type == 'event':
|
||||
line.display_name = line.value_event.name
|
||||
|
Reference in New Issue
Block a user