[ADD] survey_event_registration_generation_attachment: add attachment to survey generated event registration
This commit is contained in:
@@ -0,0 +1 @@
|
||||
from . import models
|
@@ -0,0 +1,18 @@
|
||||
# Copyright 2016-2020 Akretion France (<https://www.akretion.com>)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
"name": "Survey event registration generation",
|
||||
"version": "16.0.0.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "Elabore",
|
||||
"website": "https://www.elabore.coop",
|
||||
"category": "",
|
||||
"depends": ["survey_contact_generation","survey_event_registration_generation"],
|
||||
"data": [
|
||||
|
||||
],
|
||||
"installable": True,
|
||||
"auto_install":True,
|
||||
}
|
@@ -0,0 +1 @@
|
||||
from . import survey_user_input
|
@@ -0,0 +1,37 @@
|
||||
|
||||
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 _mark_done(self):
|
||||
res = super()._mark_done()
|
||||
|
||||
"""Generate registration when the survey is submitted"""
|
||||
for user_input in self.filtered(
|
||||
lambda r: r.survey_id.generate_registration and not self.registration_id
|
||||
):
|
||||
vals = user_input._prepare_registration()
|
||||
|
||||
registration = self.env["event.registration"].create(vals)
|
||||
self._create_registration_post_process(registration)
|
||||
self.update({"registration_id": registration.id})
|
||||
res = super()._mark_done()
|
||||
|
||||
# after all, set partner id of registration as the partner of user input
|
||||
for user_input in self:
|
||||
if user_input.registration_id and user_input.partner_id:
|
||||
user_input.registration_id.partner_id = user_input.partner_id
|
||||
return res
|
Reference in New Issue
Block a user