diff --git a/account_banking_mandate/__init__.py b/account_banking_mandate/__init__.py index e5d6460e0..cde864bae 100644 --- a/account_banking_mandate/__init__.py +++ b/account_banking_mandate/__init__.py @@ -1,5 +1,3 @@ # -*- coding: utf-8 -*- -# © 2014 Compassion CH - Cyril Sester -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models diff --git a/account_banking_mandate/models/account_invoice.py b/account_banking_mandate/models/account_invoice.py index cd6e17776..e1152569c 100644 --- a/account_banking_mandate/models/account_invoice.py +++ b/account_banking_mandate/models/account_invoice.py @@ -25,3 +25,18 @@ class AccountInvoice(models.Model): if invoice.type in ('out_invoice', 'out_refund'): res['mandate_id'] = invoice.mandate_id.id or False return res + + # If a customer pays via direct debit, it's refunds should + # be deducted form the next debit by default. The module + # account_payment_partner copies payment_mode_id from invoice + # to refund, and we also need to copy mandate from invoice to refund + @api.model + def _prepare_refund( + self, invoice, date_invoice=None, date=None, description=None, + journal_id=None): + vals = super(AccountInvoice, self)._prepare_refund( + invoice, date_invoice=date_invoice, date=date, + description=description, journal_id=journal_id) + if invoice.type == 'out_invoice': + vals['mandate_id'] = invoice.mandate_id.id + return vals diff --git a/account_banking_mandate/views/account_invoice_view.xml b/account_banking_mandate/views/account_invoice_view.xml index e562c8118..41fcc966c 100644 --- a/account_banking_mandate/views/account_invoice_view.xml +++ b/account_banking_mandate/views/account_invoice_view.xml @@ -13,7 +13,8 @@ - +