From b795f33d1730d19074e2edb5bca798cda0ff87fb Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 23 Aug 2017 16:18:45 +0200 Subject: [PATCH] Copy sale_agreement_id from invoice to refund --- agreement_account/models/account_invoice.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/agreement_account/models/account_invoice.py b/agreement_account/models/account_invoice.py index c1312f2e..33db902e 100644 --- a/agreement_account/models/account_invoice.py +++ b/agreement_account/models/account_invoice.py @@ -3,7 +3,7 @@ # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models, fields +from odoo import models, fields, api class AccountInvoice(models.Model): @@ -13,3 +13,14 @@ class AccountInvoice(models.Model): 'sale.agreement', string='Sale Agreement', ondelete='restrict', readonly=True, states={'draft': [('readonly', False)]}, track_visibility='onchange') + + @api.model + def _prepare_refund( + self, invoice, date_invoice=None, date=None, description=None, + journal_id=None): + values = super(AccountInvoice, self)._prepare_refund( + invoice, date_invoice=date_invoice, date=date, + description=description, journal_id=journal_id) + if invoice.sale_agreement_id: + values['sale_agreement_id'] = invoice.sale_agreement_id.id + return values