From 2faa65783f7f07dfeb57324785d104528f26e55e Mon Sep 17 00:00:00 2001 From: houssine Date: Tue, 18 Sep 2018 18:25:02 +0200 Subject: [PATCH] [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. --- easy_my_coop/models/account_invoice.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/easy_my_coop/models/account_invoice.py b/easy_my_coop/models/account_invoice.py index cba3b20..b485a91 100644 --- a/easy_my_coop/models/account_invoice.py +++ b/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: