diff --git a/controllers/booking.py b/controllers/booking.py index abf8286..3956547 100755 --- a/controllers/booking.py +++ b/controllers/booking.py @@ -114,7 +114,7 @@ class booking(WebsiteEventController,AuthSignupHome): return request.redirect('/booking/registration/options?event_id='+str(request.session['event_id'])) #si déjà inscrit, redirection vers page d'information - reg=request.env['event.registration'].sudo().search([('event_id','=',int(post.get('event_id'))),('email','=',post.get('email'))]) + reg=request.env['event.registration'].sudo().search([('state','!=','cancel'),('event_id','=',int(post.get('event_id'))),('email','=',post.get('email'))]) if reg and not request.session['individual_booking_event']: return http.request.render('kalachakra.booking_registration_already_registered') diff --git a/models/booking_event_registration.py b/models/booking_event_registration.py index 96c245b..7da4adc 100755 --- a/models/booking_event_registration.py +++ b/models/booking_event_registration.py @@ -1,4 +1,4 @@ -from odoo import models, fields, api +from odoo import models, fields, api,_ from odoo.exceptions import UserError, ValidationError, Warning from psycopg2 import sql, DatabaseError from dateutil.relativedelta import relativedelta @@ -124,6 +124,17 @@ class EventRegistration(models.Model): if rec.down_payment_invoice_id and rec.balance_invoice_id: rec.to_be_paid_amount=rec.down_payment_invoice_id.amount_residual+rec.balance_invoice_id.amount_residual + def action_cancel(self): + self.write({'state': 'cancel'}) + #annulation de la facture liée à l'événement + if self.invoice_id: self.invoice_id.state='cancel' + #annulation des factures de retraites + if self.down_payment_invoice_id: self.down_payment_invoice_id.state='cancel' + if self.balance_invoice_id: self.balance_invoice_id.state='cancel' + + def unlink(self): + if self.state!='cancel':raise UserError(_('This action is not allowed, please cancel the registration')) + if self.state=='cancel':raise UserError(_('This action is not allowed,the registration is already canceled')) def _compute_payment_status(self): for rec in self: rec.payment_status='not paid' @@ -138,7 +149,7 @@ class EventRegistration(models.Model): if rec.down_payment_invoice_state=='paid' and rec.balance_invoice_state=='paid' :rec.payment_status='paid' if rec.down_payment_invoice_state=='paid' and rec.balance_invoice_state!='paid':rec.payment_status='down payment paid' - if rec.payment_status in('paid','down payment paid'): + if rec.payment_status in('paid','down payment paid') and rec.state!='cancel': rec.state='open' @@ -455,7 +466,8 @@ class EventRegistration(models.Model): if event_option: if status=="super member":price_unit=event_option.booking_option_super_member_price if status=="member":price_unit=event_option.booking_option_member_price - if status=="not member" and membership_option:price_unit=event_option.booking_option_member_price + if status=="not member" and membership_option and event_option.booking_option_id.membership_product:price_unit=event_option.booking_option_price + if status=="not member" and membership_option and not event_option.booking_option_id.membership_product:price_unit=event_option.booking_option_member_price if status=="not member" and not membership_option:price_unit=event_option.booking_option_price if backoffice: if option.booking_option_id.booking_option_product_backoffice: @@ -716,8 +728,11 @@ class EventRegistration(models.Model): if event_option: if status=="super member":price_unit=event_option.booking_option_super_member_price if status=="member":price_unit=event_option.booking_option_member_price - if status=="not member" and membership_option:price_unit=event_option.booking_option_member_price + if status=="not member" and membership_option and event_option.booking_option_id.membership_product:price_unit=event_option.booking_option_price + if status=="not member" and membership_option and not event_option.booking_option_id.membership_product:price_unit=event_option.booking_option_member_price if status=="not member" and not membership_option:price_unit=event_option.booking_option_price + + if backoffice: if option.booking_option_id.booking_option_product_backoffice: price_unit=option.booking_option_price diff --git a/models/event.py b/models/event.py index ae1aba9..a85e17b 100755 --- a/models/event.py +++ b/models/event.py @@ -78,6 +78,7 @@ class KalachakraEvent(models.Model): headphone_option=fields.Boolean('headphone option') payment_required=fields.Boolean('payment required to valid a registering') display_invoice=fields.Boolean('display invoice') + teacher_picto=fields.Binary('Teacher picto') @api.depends('seats_unconfirmed', 'seats_reserved', 'seats_used') def _compute_seats_expected(self): diff --git a/models/partner.py b/models/partner.py index 4317421..307744c 100755 --- a/models/partner.py +++ b/models/partner.py @@ -103,6 +103,25 @@ class ResPartner(models.Model): res = super(ResPartner, self).create(values) country_france=self.env['res.country'].sudo().search([('name','=','France')]) if not res.country_id:res.country_id=country_france.id + #ajout du contact à la mailing liste principale + if res.email: + mailing_contact=self.env['mailing.contact'].sudo().search([('email','=',res.email)],limit=1) + + + mailing_list=self.env['mailing.list'].sudo().search([('name','=','Newsletter '+self.env.company.name)]) + if mailing_list: + if not mailing_contact: + vals={} + vals['email']=res.email + vals['name']=res.name + vals['title_id']=int(res.title) + vals['country_id']=int(res.country_id) + vals['list_ids']=[(4,int(mailing_list.id))] + mailing_contact=self.env['mailing.contact'].sudo().create(vals) + else: + if not mailing_list in mailing_contact.list_ids: + mailing_contact.sudo().write({'list_ids':[(4,int(mailing_list.id))]}) + return res def unlink(self): diff --git a/views/booking_event_templates_page_registration.xml b/views/booking_event_templates_page_registration.xml index 3678524..8d12f2c 100755 --- a/views/booking_event_templates_page_registration.xml +++ b/views/booking_event_templates_page_registration.xml @@ -9,21 +9,26 @@