|
|
@ -14,6 +14,58 @@ class EventRegistration(models.Model): |
|
|
|
free_participation=fields.Boolean(related='event_id.free_participation') |
|
|
|
with_membership=fields.Boolean('with membership') |
|
|
|
|
|
|
|
def create(self,vals): |
|
|
|
|
|
|
|
reg = super(EventRegistration, self).create(vals) |
|
|
|
if reg.event_id.booking_event: |
|
|
|
if reg._check_auto_confirmation(): |
|
|
|
reg.sudo().action_confirm() |
|
|
|
#ajout du questionnaire pour la personne inscrite |
|
|
|
questions=self.env['event.question'].search([('event_id','=',int(reg.event_id))]) |
|
|
|
if questions: |
|
|
|
for question in questions: |
|
|
|
vals={} |
|
|
|
vals['sequence']=question.sequence |
|
|
|
vals['question']=question.question |
|
|
|
vals['event_registration_id']=reg.id |
|
|
|
res=self.env['event.registration_questionnaire'].create(vals) |
|
|
|
|
|
|
|
#ajout des options pour la personne inscrite |
|
|
|
options=self.env['booking.option'].search([('event_id','=',int(reg.event_id))]) |
|
|
|
if options: |
|
|
|
for option in options: |
|
|
|
vals={} |
|
|
|
vals['booking_option_id']=int(option.booking_option_id) |
|
|
|
vals['booking_option_price']=option.booking_option_price |
|
|
|
vals['event_registration_id']=int(reg.id) |
|
|
|
res=self.env['event.registration_option'].create(vals) |
|
|
|
else: |
|
|
|
#inscription à la newsletter attachée à l'événement |
|
|
|
#si pas une retraite et présence d'une newletter rattaché à l'événement |
|
|
|
if reg.event_id.recurring_event_newsletter_id: |
|
|
|
mailing_contact=self.env['mailing.contact'].sudo().search([('email','=',reg.partner_id.email)],limit=1) |
|
|
|
#si le contact n'existe pas comme mailing contact, création |
|
|
|
if not mailing_contact: |
|
|
|
vals={} |
|
|
|
vals['email']=reg.partner_id.email |
|
|
|
vals['name']=reg.partner_id.name |
|
|
|
vals['title_id']=int(reg.partner_id.title) |
|
|
|
vals['country_id']=int(reg.partner_id.country_id) |
|
|
|
vals['list_ids']=[(4,int(reg.event_id.recurring_event_newsletter_id))] |
|
|
|
mailing_contact=self.env['mailing.contact'].sudo().create(vals) |
|
|
|
else: |
|
|
|
#si le contact existe, si la liste de diffusion n'est pas lié au contact, on l'ajoute |
|
|
|
if not reg.event_id.recurring_event_newsletter_id in mailing_contact.list_ids: |
|
|
|
mailing_contact.sudo().write({'list_ids':[(4,int(event.recurring_event_newsletter_id))]}) |
|
|
|
|
|
|
|
#inscription à la newsletter générale |
|
|
|
mailing_list=self.env['mailing.list'].sudo().search([('name','=','Newsletter '+self.env.company.name)]) |
|
|
|
if mailing_list: |
|
|
|
if not mailing_list in mailing_contact.list_ids: |
|
|
|
mailing_contact.sudo().write({'list_ids':[(4,int(mailing_list.id))]}) |
|
|
|
return reg |
|
|
|
|
|
|
|
|
|
|
|
def action_generate_participation_invoice(self,id_registration=None,payment_mode=None,membership=False): |
|
|
|
|
|
|
|
if not id_registration:id_registration=int(self.id) |
|
|
|