@ -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