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
670 B

  1. # Copyright 2019 Camptocamp SA
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import api, fields, models
  4. class ProcurementGroup(models.Model):
  5. _inherit = "procurement.group"
  6. agreement_id = fields.Many2one('agreement', readonly=True)
  7. @api.model_create_multi
  8. @api.returns('self', lambda value: value.id)
  9. def create(self, vals_list):
  10. for values in vals_list:
  11. so_id = values.get('sale_id')
  12. if so_id:
  13. agreement = self.env['sale.order'].browse(so_id).agreement_id
  14. values['agreement_id'] = agreement.id
  15. res = super().create(vals_list)
  16. return res