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.

20 lines
693 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
  6. class SaleOrder(models.Model):
  7. _inherit = 'sale.order'
  8. agreement_id = fields.Many2one(
  9. 'agreement', string='Agreement', ondelete='restrict',
  10. track_visibility='onchange', readonly=True,
  11. states={'draft': [('readonly', False)], 'sent': [('readonly', False)]})
  12. def _prepare_invoice(self):
  13. vals = super(SaleOrder, self)._prepare_invoice()
  14. vals['agreement_id'] = self.agreement_id.id or False
  15. return vals