Browse Source

extourne suite annulation du don

master
root 3 years ago
parent
commit
25ebabf46c
1 changed files with 42 additions and 0 deletions
  1. +42
    -0
      models/donation.py

+ 42
- 0
models/donation.py View File

@ -99,6 +99,48 @@ class DonationDonation(models.Model):
)
html_content_print=fields.Html('html content print')
def done2cancel(self):
"""from Done state to Cancel state"""
for donation in self:
if donation.tax_receipt_id:
raise UserError(
_(
"You cannot cancel this donation because "
"it is linked to the tax receipt %s. You should first "
"delete this tax receipt (but it may not be legally "
"allowed)."
)
% donation.tax_receipt_id.number
)
#if donation.move_id:
#donation.move_id.button_cancel()
#donation.move_id.unlink()
donation.write({"state": "cancel"})
donation.partner_id._update_donor_rank()
donation.reverse_accounting_entries()
def reverse_accounting_entries(self):
move=self.env['account.move'].search([('id','=',int(self.move_id))])
#création de la pièce comptable d'extourne
vals={}
vals['ref']='Extourne de '+ move.name
vals['date']=datetime.now()
vals['journal_id']=int(move.journal_id)
vals['reversed_entry_id']=int(move.id)
move_r=self.env['account.move'].create(vals)
#création des écritures comptables d'extourne
for line in move.line_ids:
vals={}
vals['move_id']=int(move_r.id)
vals['partner_id']=int(line.partner_id)
vals['account_id']=int(line.account_id)
vals['debit']=line.credit
vals['credit']=line.debit
vals['quantity']=line.quantity
vals['date']=move_r.date
line_r=self.env['account.move.line'].with_context(check_move_validity=False).create(vals)
move_r._post()
def _compute_year_donation_date(self):
for rec in self:


Loading…
Cancel
Save