Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- line_mission = fields.Many2many('hr.employee', string='Employés', help="Employee sent on mission",
- copy=True, auto_join=True,readonly=True, states={'draft': [('readonly', False)]})
- @api.multi
- @api.constrains('mission_start_date', 'mission_end_date')
- @api.depends('line_mission.name')
- def _check_date(self):
- for mission in self:
- employee = self.env['hr.employee'].search_count([('name', '=', self.id)])
- domain = [
- ('mission_start_date', '<=', mission.mission_end_date),
- ('mission_end_date', '>=', mission.mission_start_date),
- ('id', '!=', mission.id),
- ('state', 'not in', ['end_mission']),
- ]
- nmissions = self.search_count(domain)
- if employee in mission.line_mission.name and nmissions:
- 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