@ -100,8 +100,12 @@ class EventRegistration(models.Model):
to_be_paid_amount = fields . Monetary ( ' to be paid amount ' , compute = ' _compute_to_be_paid_amount ' , currency_field = ' currency_id ' )
to_be_paid_amount = fields . Monetary ( ' to be paid amount ' , compute = ' _compute_to_be_paid_amount ' , currency_field = ' currency_id ' )
payment_adjustement = fields . Monetary ( ' payment adjustement ' , currency_field = ' currency_id ' )
payment_adjustement = fields . Monetary ( ' payment adjustement ' , currency_field = ' currency_id ' )
individual_room = fields . Boolean ( ' Individual room ' , compute = ' compute_individual_room ' )
individual_room = fields . Boolean ( ' Individual room ' , compute = ' compute_individual_room ' )
#individual booking fields
start_day_individual_booking = fields . Date ( ' Start day individual booking ' )
start_day_individual_booking = fields . Date ( ' Start day individual booking ' )
end_day_individual_booking = fields . Date ( ' End day individual booking ' )
end_day_individual_booking = fields . Date ( ' End day individual booking ' )
days_duration = fields . Integer ( ' duration in days ' )
price_individual_booking = fields . Monetary ( ' price individual booking ' , currency_field = ' currency_id ' )
def compute_individual_room ( self ) :
def compute_individual_room ( self ) :
@ -332,30 +336,33 @@ class EventRegistration(models.Model):
else :
else :
status = ' not member '
status = ' not member '
if event . individual_booking_event :
product_price = reg . price_individual_booking
else :
product_price = event . booking_price
if status == ' not member ' : product_price = event . booking_price
if status == ' member ' : product_price = event . booking_member_price
if status == ' super member ' : product_price = event . booking_super_member_price
product_price = event . booking_price
if status == ' not member ' : product_price = event . booking_price
if status == ' member ' : product_price = event . booking_member_price
if status == ' super member ' : product_price = event . booking_super_member_price
#Prix à appliquer au produit si paiement de l'adhésion
membership_option = False
#membership_product=self.env['event.membership_product'].search([])
membership_product = self . env [ ' product.product ' ] . sudo ( ) . search ( [ ( ' membership_product ' , ' = ' , True ) ] , limit = 1 )
if membership_product :
if selected_registrant_options :
for opt in selected_registrant_options :
#raise Warning("opt.booking_option_id="+str(opt.booking_option_id.id)+" membership_product.id="+str(membership_product.id))
if opt . booking_option_id . id == membership_product . id :
membership_option = True
if status != " super member " :
product_price = event . booking_member_price
#Prix à appliquer au produit si paiement de l'adhésion
membership_option = False
#membership_product=self.env['event.membership_product'].search([])
membership_product = self . env [ ' product.product ' ] . sudo ( ) . search ( [ ( ' membership_product ' , ' = ' , True ) ] , limit = 1 )
if membership_product :
if selected_registrant_options :
for opt in selected_registrant_options :
#raise Warning("opt.booking_option_id="+str(opt.booking_option_id.id)+" membership_product.id="+str(membership_product.id))
if opt . booking_option_id . id == membership_product . id :
membership_option = True
if self . payment_adjustement != 0 :
product_price = product_price + self . payment_adjustement
if status != " super member " :
product_price = event . booking_member_price
if self . payment_adjustement != 0 :
product_price = product_price + self . payment_adjustement
#calcul du montant total à régler
#calcul du montant total à régler
if end_of_stay_invoice : product_price = 0
if end_of_stay_invoice : product_price = 0
@ -407,7 +414,10 @@ class EventRegistration(models.Model):
vals [ ' product_id ' ] = int ( event . booking_product_id )
vals [ ' product_id ' ] = int ( event . booking_product_id )
vals [ ' quantity ' ] = 1
vals [ ' quantity ' ] = 1
vals [ ' price_unit ' ] = product_price
vals [ ' price_unit ' ] = product_price
vals [ ' name ' ] = event . booking_product_id . name
if event . individual_booking_event :
vals [ ' name ' ] = event . booking_product_id . name + ' du ' + str ( reg . start_day_individual_booking ) + ' au ' + str ( reg . end_day_individual_booking ) + ' - ' + str ( reg . days_duration ) + ' jours '
else :
vals [ ' name ' ] = event . booking_product_id . name
vals [ ' account_id ' ] = int ( account_credit . id )
vals [ ' account_id ' ] = int ( account_credit . id )
@ -500,7 +510,7 @@ class EventRegistration(models.Model):
else :
else :
reg . end_of_stay_invoice_id = invoice . id
reg . end_of_stay_invoice_id = invoice . id
user = self . env [ ' res.users ' ] . search ( [ ( ' email ' , ' ilike ' , reg . partner_id . email ) ] )
user = self . env [ ' res.users ' ] . search ( [ ( ' email ' , ' ilike ' , reg . partner_id . email ) ] , limit = 1 )
invoice . invoice_user_id = user . id
invoice . invoice_user_id = user . id
invoice . user_id = user . id
invoice . user_id = user . id
@ -550,8 +560,20 @@ class EventRegistration(models.Model):
vals [ ' move_id ' ] = invoice . id
vals [ ' move_id ' ] = invoice . id
vals [ ' product_id ' ] = int ( event . booking_product_id )
vals [ ' product_id ' ] = int ( event . booking_product_id )
vals [ ' quantity ' ] = 1
vals [ ' quantity ' ] = 1
vals [ ' price_unit ' ] = event . booking_down_payment
vals [ ' name ' ] = ' Acompte ' + event . booking_product_id . name
if event . individual_booking_event :
if product_price < event . booking_down_payment :
vals [ ' price_unit ' ] = product_price
else :
vals [ ' price_unit ' ] = event . booking_down_payment
vals [ ' name ' ] = ' Acompte ' + event . booking_product_id . name + ' du ' + str ( reg . start_day_individual_booking ) + ' au ' + str ( reg . end_day_individual_booking ) + ' - ' + str ( reg . days_duration ) + ' jour(s) '
else :
vals [ ' price_unit ' ] = event . booking_down_payment
vals [ ' name ' ] = ' Acompte ' + event . booking_product_id . name
vals [ ' account_id ' ] = int ( account_credit . id )
vals [ ' account_id ' ] = int ( account_credit . id )
@ -561,7 +583,13 @@ class EventRegistration(models.Model):
# #debit_line
# #debit_line
vals_d = { }
vals_d = { }
vals_d [ ' move_id ' ] = invoice . id
vals_d [ ' move_id ' ] = invoice . id
vals_d [ ' debit ' ] = event . booking_down_payment
if event . individual_booking_event :
if product_price < event . booking_down_payment :
vals_d [ ' debit ' ] = product_price
else :
vals_d [ ' debit ' ] = event . booking_down_payment
else :
vals_d [ ' debit ' ] = event . booking_down_payment
vals_d [ ' credit ' ] = 0
vals_d [ ' credit ' ] = 0
vals_d [ ' date ' ] = datetime . now ( )
vals_d [ ' date ' ] = datetime . now ( )
vals_d [ ' partner_id ' ] = int ( reg . partner_id )
vals_d [ ' partner_id ' ] = int ( reg . partner_id )
@ -569,7 +597,14 @@ class EventRegistration(models.Model):
vals_d [ ' name ' ] = ' Acompte ' + event . booking_product_id . name
vals_d [ ' name ' ] = ' Acompte ' + event . booking_product_id . name
vals_d [ ' account_id ' ] = int ( account_debit . id )
vals_d [ ' account_id ' ] = int ( account_debit . id )
vals_d [ ' quantity ' ] = 1
vals_d [ ' quantity ' ] = 1
vals_d [ ' price_unit ' ] = event . booking_down_payment
if event . individual_booking_event :
if product_price < event . booking_down_payment :
vals_d [ ' price_unit ' ] = product_price
else :
vals_d [ ' price_unit ' ] = event . booking_down_payment
else :
vals_d [ ' price_unit ' ] = event . booking_down_payment
vals_d [ ' exclude_from_invoice_tab ' ] = True
vals_d [ ' exclude_from_invoice_tab ' ] = True
@ -604,7 +639,14 @@ class EventRegistration(models.Model):
vals [ ' move_id ' ] = invoice . id
vals [ ' move_id ' ] = invoice . id
vals [ ' product_id ' ] = int ( event . booking_product_id )
vals [ ' product_id ' ] = int ( event . booking_product_id )
vals [ ' quantity ' ] = 1
vals [ ' quantity ' ] = 1
vals [ ' price_unit ' ] = product_price - event . booking_down_payment
if event . individual_booking_event :
if product_price < event . booking_down_payment :
vals [ ' price_unit ' ] = 0
else :
vals [ ' price_unit ' ] = product_price - event . booking_down_payment
else :
vals [ ' price_unit ' ] = product_price - event . booking_down_payment
vals [ ' name ' ] = ' solde ' + event . booking_product_id . name
vals [ ' name ' ] = ' solde ' + event . booking_product_id . name
vals [ ' account_id ' ] = int ( account_credit . id )
vals [ ' account_id ' ] = int ( account_credit . id )
@ -631,7 +673,13 @@ class EventRegistration(models.Model):
# #debit_line
# #debit_line
vals_d = { }
vals_d = { }
vals_d [ ' move_id ' ] = invoice . id
vals_d [ ' move_id ' ] = invoice . id
vals_d [ ' debit ' ] = product_price - event . booking_down_payment
if event . individual_booking_event :
if product_price < event . booking_down_payment :
vals [ ' debit ' ] = 0
else :
vals [ ' debit ' ] = product_price - event . booking_down_payment
else :
vals_d [ ' debit ' ] = product_price - event . booking_down_payment
vals_d [ ' credit ' ] = 0
vals_d [ ' credit ' ] = 0
vals_d [ ' date ' ] = datetime . now ( )
vals_d [ ' date ' ] = datetime . now ( )
vals_d [ ' partner_id ' ] = int ( reg . partner_id )
vals_d [ ' partner_id ' ] = int ( reg . partner_id )
@ -639,7 +687,13 @@ class EventRegistration(models.Model):
vals_d [ ' name ' ] = ' solde ' + event . booking_product_id . name
vals_d [ ' name ' ] = ' solde ' + event . booking_product_id . name
vals_d [ ' account_id ' ] = int ( account_debit . id )
vals_d [ ' account_id ' ] = int ( account_debit . id )
vals_d [ ' quantity ' ] = 1
vals_d [ ' quantity ' ] = 1
vals_d [ ' price_unit ' ] = product_price - event . booking_down_payment
if event . individual_booking_event :
if product_price < event . booking_down_payment :
vals [ ' price_unit ' ] = 0
else :
vals [ ' price_unit ' ] = product_price - event . booking_down_payment
else :
vals_d [ ' price_unit ' ] = product_price - event . booking_down_payment
vals_d [ ' exclude_from_invoice_tab ' ] = True
vals_d [ ' exclude_from_invoice_tab ' ] = True