|
@ -195,26 +195,32 @@ class EventRegistration(models.Model): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def remove_invoice(self): |
|
|
def remove_invoice(self): |
|
|
if self.invoice_id and self.invoice_state!='paid': |
|
|
|
|
|
invoice=self.env['account.move'].sudo().search([('id','=',int(self.invoice_id))]) |
|
|
|
|
|
invoice.state='draft' |
|
|
|
|
|
|
|
|
|
|
|
#invoice2=self.env['account.move'].sudo().search([('payment_reference','=',invoice.payment_reference)]) |
|
|
|
|
|
#invoice2.unlink() |
|
|
|
|
|
#raise Warning(invoice2) |
|
|
|
|
|
|
|
|
|
|
|
if self.down_payment_invoice_id and self.down_payment_invoice_state!='paid': |
|
|
|
|
|
#si la facture d'acompte est payé, on le la supprime pas |
|
|
|
|
|
invoice=self.env['account.move'].sudo().search([('id','=',int(self.down_payment_invoice_id))]) |
|
|
|
|
|
invoice.state='draft' |
|
|
|
|
|
# self.env['account.move'].search([('id','=',int(self.down_payment_invoice_id))]).unlink() |
|
|
|
|
|
# self.down_payment_invoice_id=False |
|
|
|
|
|
|
|
|
invoice=self.env['account.move'].sudo().search([('id','=',int(self.invoice_id))]) |
|
|
|
|
|
if invoice: |
|
|
|
|
|
if invoice.payment_state!='paid': |
|
|
|
|
|
invoice.state='draft' |
|
|
|
|
|
invoice_id=self.invoice_id |
|
|
|
|
|
self.invoice_id=False |
|
|
|
|
|
self.env['account.move'].sudo().search([('id','=',int(invoice_id))]).unlink() |
|
|
|
|
|
|
|
|
|
|
|
invoice=self.env['account.move'].sudo().search([('id','=',int(self.down_payment_invoice_id))]) |
|
|
|
|
|
if invoice: |
|
|
|
|
|
if invoice.payment_state!='paid': |
|
|
|
|
|
invoice.state='draft' |
|
|
|
|
|
invoice_id=self.down_payment_invoice_id |
|
|
|
|
|
self.down_payment_invoice_id=False |
|
|
|
|
|
self.env['account.move'].sudo().search([('id','=',int(invoice_id))]).unlink() |
|
|
|
|
|
|
|
|
if self.balance_invoice_id and self.balance_invoice_state!='paid': |
|
|
|
|
|
invoice=self.env['account.move'].sudo().search([('id','=',int(self.balance_invoice_id))]) |
|
|
|
|
|
invoice.state='draft' |
|
|
|
|
|
# self.env['account.move'].search([('id','=',int(self.balance_invoice_id))]).unlink() |
|
|
|
|
|
# self.balance_invoice_id=False |
|
|
|
|
|
|
|
|
invoice=self.env['account.move'].sudo().search([('id','=',int(self.balance_invoice_id))]) |
|
|
|
|
|
if invoice: |
|
|
|
|
|
if invoice.payment_state!='paid': |
|
|
|
|
|
invoice.state='draft' |
|
|
|
|
|
invoice_id=self.balance_invoice_id |
|
|
|
|
|
self.balance_invoice_id=False |
|
|
|
|
|
self.env['account.move'].sudo().search([('id','=',int(invoice_id))]).unlink() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return True |
|
|
return True |
|
|
|
|
|
|
|
|
def remove_donation(self): |
|
|
def remove_donation(self): |
|
@ -239,8 +245,12 @@ class EventRegistration(models.Model): |
|
|
#suppression des dons existants lié aux options de l'inscription |
|
|
#suppression des dons existants lié aux options de l'inscription |
|
|
self.remove_donation() |
|
|
self.remove_donation() |
|
|
else: |
|
|
else: |
|
|
invoice=self.env['account.move'].sudo().search([('id','=',int(self.end_of_stay_invoice_id))]) |
|
|
|
|
|
invoice.state='draft' |
|
|
|
|
|
|
|
|
end_invoice=self.env['account.move'].sudo().search([('id','=',int(self.end_of_stay_invoice_id))]) |
|
|
|
|
|
if end_invoice: |
|
|
|
|
|
if end_invoice.payment_state!='paid': |
|
|
|
|
|
invoice_id=self.end_of_stay_invoice_id |
|
|
|
|
|
self.end_of_stay_invoice_id=False |
|
|
|
|
|
self.env['account.move'].sudo().search([('id','=',int(invoice_id))]).unlink() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -256,7 +266,17 @@ class EventRegistration(models.Model): |
|
|
if not event.booking_product_id: raise Warning('product missing for event booking') |
|
|
if not event.booking_product_id: raise Warning('product missing for event booking') |
|
|
|
|
|
|
|
|
#Prix à appliquer au produit en fonction du statut de l'inscrit |
|
|
#Prix à appliquer au produit en fonction du statut de l'inscrit |
|
|
status=reg.partner_id.member_status |
|
|
|
|
|
|
|
|
if reg.partner_id.email==reg.email: |
|
|
|
|
|
status=reg.partner_id.member_status |
|
|
|
|
|
#le participant n'est pas la personne qui s'est connecté |
|
|
|
|
|
else: |
|
|
|
|
|
participant=self.env['res.partner'].sudo().search([('email','=',reg.email)],limit=1) |
|
|
|
|
|
if participant: |
|
|
|
|
|
status=participant.member_status |
|
|
|
|
|
else: |
|
|
|
|
|
status='not member' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
product_price=event.booking_price |
|
|
product_price=event.booking_price |
|
|
if status=='not member':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=='member':product_price=event.booking_member_price |
|
@ -280,9 +300,13 @@ class EventRegistration(models.Model): |
|
|
#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 |
|
|
|
|
|
|
|
|
#création du devis sans accompte |
|
|
|
|
|
|
|
|
#création du devis sans acompte |
|
|
|
|
|
|
|
|
if (not reg.down_payment and reg.invoice_state!='paid') or (end_of_stay_invoice): |
|
|
if (not reg.down_payment and reg.invoice_state!='paid') or (end_of_stay_invoice): |
|
|
|
|
|
if not selected_registrant_options and end_of_stay_invoice : |
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#création de la facture |
|
|
#création de la facture |
|
|
vals={} |
|
|
vals={} |
|
|
|
|
|
|
|
@ -308,7 +332,7 @@ class EventRegistration(models.Model): |
|
|
|
|
|
|
|
|
vals['move_type']='out_invoice' |
|
|
vals['move_type']='out_invoice' |
|
|
vals['state']='draft' |
|
|
vals['state']='draft' |
|
|
#vals['currency_id']=self.currency_id.id |
|
|
|
|
|
|
|
|
|
|
|
invoice=self.env['account.move'].sudo().create(vals) |
|
|
invoice=self.env['account.move'].sudo().create(vals) |
|
|
invoice.state='posted' |
|
|
invoice.state='posted' |
|
|
invoice.name='REC'+str(invoice.id) |
|
|
invoice.name='REC'+str(invoice.id) |
|
@ -343,8 +367,10 @@ class EventRegistration(models.Model): |
|
|
vals_d['price_unit']=product_price |
|
|
vals_d['price_unit']=product_price |
|
|
vals_d['exclude_from_invoice_tab']=True |
|
|
vals_d['exclude_from_invoice_tab']=True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#statut payment=paid |
|
|
invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals_d) |
|
|
invoice_line=self.env['account.move.line'].with_context(check_move_validity=False).sudo().create(vals_d) |
|
|
|
|
|
#statut payment=not_paid |
|
|
l=self.env['account.move.line'].sudo().search([('move_id','=',invoice.id),('balance','<',0)]) |
|
|
l=self.env['account.move.line'].sudo().search([('move_id','=',invoice.id),('balance','<',0)]) |
|
|
l.partner_id=int(reg.partner_id) |
|
|
l.partner_id=int(reg.partner_id) |
|
|
|
|
|
|
|
|