Browse Source

Copy sale_agreement_id from invoice to refund

pull/95/head
Alexis de Lattre 7 years ago
parent
commit
b795f33d17
  1. 13
      agreement_account/models/account_invoice.py

13
agreement_account/models/account_invoice.py

@ -3,7 +3,7 @@
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# 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
Loading…
Cancel
Save