You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
949 B

  1. # -*- coding: utf-8 -*-
  2. # © 2017 Akretion (http://www.akretion.com)
  3. # @author: Alexis de Lattre <alexis.delattre@akretion.com>
  4. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  5. from odoo import models, fields, api
  6. class AccountInvoice(models.Model):
  7. _inherit = 'account.invoice'
  8. agreement_id = fields.Many2one(
  9. 'agreement', string='Agreement', ondelete='restrict',
  10. readonly=True, states={'draft': [('readonly', False)]},
  11. track_visibility='onchange')
  12. @api.model
  13. def _prepare_refund(
  14. self, invoice, date_invoice=None, date=None, description=None,
  15. journal_id=None):
  16. values = super(AccountInvoice, self)._prepare_refund(
  17. invoice, date_invoice=date_invoice, date=date,
  18. description=description, journal_id=journal_id)
  19. if invoice.agreement_id:
  20. values['agreement_id'] = invoice.agreement_id.id
  21. return values