Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. line_mission = fields.Many2many('hr.employee', string='Employés', help="Employee sent on mission",
  2. copy=True, auto_join=True,readonly=True, states={'draft': [('readonly', False)]})
  3.  
  4. @api.multi
  5. @api.constrains('mission_start_date', 'mission_end_date')
  6. @api.depends('line_mission.name')
  7. def _check_date(self):
  8. for mission in self:
  9. employee = self.env['hr.employee'].search_count([('name', '=', self.id)])
  10. domain = [
  11. ('mission_start_date', '<=', mission.mission_end_date),
  12. ('mission_end_date', '>=', mission.mission_start_date),
  13. ('id', '!=', mission.id),
  14. ('state', 'not in', ['end_mission']),
  15. ]
  16. nmissions = self.search_count(domain)
  17. if employee in mission.line_mission.name and nmissions:
  18. raise UserError(_('Vous ne pouvez pas avoir 2 missions qui se chevauchent le même jour!'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement