|
|
@ -208,32 +208,70 @@ class EventRegistration(models.Model): |
|
|
|
if invoice: |
|
|
|
if invoice.payment_state!='paid': |
|
|
|
invoice.state='draft' |
|
|
|
invoice.posted_before=False |
|
|
|
invoice_id=self.invoice_id |
|
|
|
self.invoice_id=False |
|
|
|
|
|
|
|
#suppression des lignes de paiements liés à la facture |
|
|
|
move_line=self.env['account.move.line'].sudo().search([('move_id','=',int(invoice_id))]) |
|
|
|
if move_line: |
|
|
|
for m in move_line: |
|
|
|
self.env['account.payment.line'].sudo().search([('move_line_id','=',int(m.id))]).unlink() |
|
|
|
|
|
|
|
#suppression des paiements liés à la facture |
|
|
|
self.env['account.payment'].sudo().search([('move_id','=',int(invoice_id))]).unlink() |
|
|
|
|
|
|
|
#suppression des écritures comptables lié à la facture |
|
|
|
self.env['account.move.line'].sudo().search([('move_id','=',int(invoice_id))]).unlink() |
|
|
|
#suppression de la facture |
|
|
|
|
|
|
|
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() |
|
|
|
|
|
|
|
invoice=self.env['account.move'].sudo().search([('id','=',int(self.balance_invoice_id))]) |
|
|
|
if invoice: |
|
|
|
if self.down_payment_invoice_id: |
|
|
|
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.balance_invoice_id |
|
|
|
self.balance_invoice_id=False |
|
|
|
invoice.posted_before=False |
|
|
|
invoice_id=self.down_payment_invoice_id |
|
|
|
self.down_payment_invoice_id=False |
|
|
|
#suppression des lignes de paiements liés à la facture |
|
|
|
move_line=self.env['account.move.line'].sudo().search([('move_id','=',int(invoice_id))]) |
|
|
|
if move_line: |
|
|
|
for m in move_line: |
|
|
|
self.env['account.payment.line'].sudo().search([('move_line_id','=',int(m.id))]).unlink() |
|
|
|
|
|
|
|
#suppression des paiements liés à la facture |
|
|
|
self.env['account.payment'].sudo().search([('move_id','=',int(invoice_id))]).unlink() |
|
|
|
|
|
|
|
#suppression des écritures comptables lié à la facture |
|
|
|
self.env['account.move.line'].sudo().search([('move_id','=',int(invoice_id))]).unlink() |
|
|
|
#suppression de la facture |
|
|
|
|
|
|
|
self.env['account.move'].sudo().search([('id','=',int(invoice_id))]).unlink() |
|
|
|
|
|
|
|
if self.balance_invoice_id: |
|
|
|
invoice=self.env['account.move'].sudo().search([('id','=',int(self.balance_invoice_id))]) |
|
|
|
if invoice: |
|
|
|
if invoice.payment_state!='paid': |
|
|
|
invoice.state='draft' |
|
|
|
invoice.posted_before=False |
|
|
|
invoice_id=self.balance_invoice_id |
|
|
|
self.balance_invoice_id=False |
|
|
|
#suppression des lignes de paiements liés à la facture |
|
|
|
move_line=self.env['account.move.line'].sudo().search([('move_id','=',int(invoice_id))]) |
|
|
|
if move_line: |
|
|
|
for m in move_line: |
|
|
|
self.env['account.payment.line'].sudo().search([('move_line_id','=',int(m.id))]).unlink() |
|
|
|
|
|
|
|
#suppression des paiements liés à la facture |
|
|
|
self.env['account.payment'].sudo().search([('move_id','=',int(invoice_id))]).unlink() |
|
|
|
|
|
|
|
#suppression des écritures comptables lié à la facture |
|
|
|
self.env['account.move.line'].sudo().search([('move_id','=',int(invoice_id))]).unlink() |
|
|
|
#suppression de la facture |
|
|
|
|
|
|
|
self.env['account.move'].sudo().search([('id','=',int(invoice_id))]).unlink() |
|
|
|
|
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|