diff --git a/models/hr_timesheet.py b/models/hr_timesheet.py index aedc05c34ccdd300a307bed0b5c0d10a3cbdaabd..04e190e233099b44c51d24eef4a39ef5825229d6 100644 --- a/models/hr_timesheet.py +++ b/models/hr_timesheet.py @@ -60,12 +60,26 @@ class ScopHrTimesheet(models.Model): def onchange_project_id(self): self.partner_id = self.project_id.partner_id + # ------------------------------------------------------ + # Override ORM + # ------------------------------------------------------ + @api.multi + def unlink(self): + for timesheet in self: + if timesheet.state in ['submit', 'valid']: + raise UserError('Vous ne pouvez pas supprimer une ' + 'ligne de temps soumise ou validée') + super(ScopHrTimesheet, self).unlink() + # ------------------------------------------------------ # Actions # ------------------------------------------------------ @api.multi def action_submit_timesheet_lines(self): - if any(time.state != 'draft' or time.sheet_id for time in self): + """ + Crée une feuille de temps avec les lignes sélectionnées + """ + if any(time.state != 'to_report' or time.sheet_id for time in self): raise UserError( "Vous ne pouvez pas insérer 2 fois la même ligne !") if len(self.mapped('employee_id')) != 1: