diff --git a/controllers/kalachakra.py b/controllers/kalachakra.py index dfa27be..ff53694 100644 --- a/controllers/kalachakra.py +++ b/controllers/kalachakra.py @@ -253,31 +253,7 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing): request.session['res_id']=res.id - #inscription à la newsletter attachée à l'événement - mailing_contact=request.env['mailing.contact'].sudo().search([('email','=',partner.email)]) - if not mailing_contact: - vals={} - vals['email']=partner.email - vals['name']=partner.name+' '+str(partner.firstname) - vals['title_id']=partner.title - vals['country_id']=int(partner.country_id) - vals['list_ids']=[(4,int(event.recurring_event_newsletter_id))] - mailing_contact=request.env['mailing.contact'].sudo().create(vals) - - if event.recurring_event_newsletter_id: - if not event.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=request.env['mailing.list'].sudo().search([('name','=','Newsletter '+request.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 http.request.render('kalachakra.registration_step2',data) @http.route(['/kalachakra/onthespotpayment'], type='http', auth='public', website=True, sitemap=False,csrf=False) diff --git a/models/booking_event_registration.py b/models/booking_event_registration.py index 09f8020..2337aad 100644 --- a/models/booking_event_registration.py +++ b/models/booking_event_registration.py @@ -117,33 +117,14 @@ class EventRegistration(models.Model): def _read_group_room_ids(self, stages, domain, order): return self.env['booking.room'].search([]) - @api.model_create_multi + @api.model def create(self, vals_list): - registrations = super(EventRegistration, self).create(vals_list) - if registrations._check_auto_confirmation(): - registrations.sudo().action_confirm() - - #ajout du questionnaire pour la personne inscrite - questions=self.env['event.question'].search([('event_id','=',int(registrations.event_id))]) - if questions: - for question in questions: - vals={} - vals['sequence']=question.sequence - vals['question']=question.question - vals['event_registration_id']=registrations.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(registrations.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(registrations.id) - res=self.env['event.registration_option'].create(vals) - - return registrations + + reg = super(EventRegistration, self).create(vals_list) + + + + return reg def action_event_registration_order(self): return True diff --git a/models/event.py b/models/event.py index 82134a3..eb1709d 100644 --- a/models/event.py +++ b/models/event.py @@ -77,7 +77,34 @@ class KalachakraEvent(models.Model): if vals.get('date_begin') or vals.get('date_end') or vals.get('name'): self.update_event_google_agenda() - + #s'il existe des événements liés à celui-ci, mise à jour de ceux-ci + #uniquement sur les champs suivants : nom, liste de diffusion, lien zoom, type de participation, lien en savoir plus + child_events=self.env['event.event'].search([('parent_event_id','=', int(self.id))]) + if child_events: + + for child_event in child_events: + + child_event.name=self.name + child_event.recurring_event_newsletter_id=self.recurring_event_newsletter_id + child_event.find_out_more_link=self.find_out_more_link + child_event.online_event=self.online_event + child_event.auto_confirm=self.auto_confirm + child_event.seats_limited=self.seats_limited + child_event.seats_max=self.seats_max + child_event.organizer_id=self.organizer_id + child_event.user_id=self.user_id + child_event.address_id=self.address_id + child_event.online_link=self.online_link + child_event.online_id=self.online_id + child_event.online_password=self.online_password + + + + + + + + def _compute_generated_events(self): for rec in self: diff --git a/models/event_registration.py b/models/event_registration.py index 355e3f0..cc2b94e 100644 --- a/models/event_registration.py +++ b/models/event_registration.py @@ -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) diff --git a/models/mailing_list.py b/models/mailing_list.py index 0e32a01..21bd4c9 100644 --- a/models/mailing_list.py +++ b/models/mailing_list.py @@ -48,7 +48,7 @@ class MailingContact(models.Model): def create(self, values): res = super(MailingContact, self).create(values) - #ajout du contact à la liste de diffusion + #ajout du contact à la liste de diffusion de sendinblue res.create_sendinblue_contact() return res