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.

35 lines
1.0 KiB

  1. # © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import models, fields
  4. class Agreement(models.Model):
  5. _name = 'agreement'
  6. _description = 'Agreement'
  7. code = fields.Char(required=True, copy=False)
  8. name = fields.Char(required=True)
  9. partner_id = fields.Many2one(
  10. 'res.partner', string='Partner', ondelete='restrict', required=True,
  11. domain=[('parent_id', '=', False)])
  12. active = fields.Boolean(default=True)
  13. signature_date = fields.Date()
  14. start_date = fields.Date()
  15. end_date = fields.Date()
  16. def name_get(self):
  17. res = []
  18. for agr in self:
  19. name = agr.name
  20. if agr.code:
  21. name = u'[%s] %s' % (agr.code, agr.name)
  22. res.append((agr.id, name))
  23. return res
  24. _sql_constraints = [(
  25. 'code_partner_unique',
  26. 'unique(code, partner_id)',
  27. 'This agreement code already exists for this partner!'
  28. )]