Browse Source

[FIX] Fix release capital request reconciled with a credit note

In the case where a release capital request is reconciled with a credit
note(when you want to cancel properly a capital release request from an
accounting point of view). In the confirm_paid function the order of the
invoices are not always the same. Some time you get the credit note
first and some times you get the original invoice first. it leads to
problem in case of the credit note go first. this commit fix the
problem.
pull/1/head
houssine 6 years ago
parent
commit
2faa65783f
  1. 3
      easy_my_coop/models/account_invoice.py

3
easy_my_coop/models/account_invoice.py

@ -72,11 +72,12 @@ class account_invoice(models.Model):
@api.multi
def confirm_paid(self):
for invoice in self:
#self.env.cr.commit()
super(account_invoice, invoice).confirm_paid()
# we check if there is an open refund for this invoice. in this case we
# don't run the process_subscription function as the invoice has been
# reconciled with a refund and not a payment.
refund = self.search([('type', '=', 'out_refund'), ('origin', '=', invoice.number)]).filtered(lambda record: record.state == 'open')
refund = self.search([('type', '=', 'out_refund'), ('origin', '=', invoice.move_name)])
if invoice.partner_id.cooperator and invoice.release_capital_request \
and invoice.type == 'out_invoice' and not refund:

Loading…
Cancel
Save