From 599d06aba5a51d2fffe9a46632d05e892f8cbb33 Mon Sep 17 00:00:00 2001 From: houssine Date: Thu, 6 Apr 2017 16:56:50 +0200 Subject: [PATCH] [FIX] call the set_effective_cooperator parent function only in case of deferred payment method --- easy_my_coop/models/account_invoice.py | 5 +++-- easy_my_coop_online_payment/models/coop.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/easy_my_coop/models/account_invoice.py b/easy_my_coop/models/account_invoice.py index c27521b..5bec650 100644 --- a/easy_my_coop/models/account_invoice.py +++ b/easy_my_coop/models/account_invoice.py @@ -62,8 +62,8 @@ class account_invoice(models.Model): @api.multi def confirm_paid(self): - super(account_invoice, self).confirm_paid() for invoice in self: + super(account_invoice, invoice).confirm_paid() if invoice.partner_id.cooperator and invoice.release_capital_request and invoice.type == 'out_invoice': effective_date = datetime.now().strftime("%d/%m/%Y") #take the effective date from the payment. by default the confirmation date is the payment date @@ -72,7 +72,8 @@ class account_invoice(models.Model): effective_date = move_line.date invoice.subscription_request.state = 'paid' - +# payment_transaction = self.env['payment.transaction'].search([('release_capital_request','=',invoice.id)]) +# if len(payment_transaction) == 0: invoice.post_process_confirm_paid(effective_date) return True diff --git a/easy_my_coop_online_payment/models/coop.py b/easy_my_coop_online_payment/models/coop.py index aacbd36..e0ab4de 100644 --- a/easy_my_coop_online_payment/models/coop.py +++ b/easy_my_coop_online_payment/models/coop.py @@ -10,4 +10,13 @@ class SubscriptionRequest(models.Model): def send_capital_release_request(self, invoice): if self.payment_type == 'deferred': super(SubscriptionRequest, self).send_capital_release_request(invoice) + return True + +class AccountInvoice(models.Model): + _inherit = 'account.invoice' + + def post_process_confirm_paid(self, effective_date): + if self.payment_type == 'deferred': + self.set_cooperator_effective(effective_date) + return True \ No newline at end of file