From 3484a86e61837bbf721d0ca4f1b998544142f51a Mon Sep 17 00:00:00 2001 From: Andrea Stirpe Date: Mon, 1 Oct 2018 11:49:59 +0200 Subject: [PATCH] [FIX] hr_timesheet_sheet: "Refuse" button name (#134) --- hr_timesheet_sheet/__manifest__.py | 2 +- .../models/hr_timesheet_sheet.py | 4 +++ .../tests/test_hr_timesheet_sheet.py | 26 +++++++++++++++++++ .../views/hr_timesheet_sheet_views.xml | 2 +- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/hr_timesheet_sheet/__manifest__.py b/hr_timesheet_sheet/__manifest__.py index 580531d7d..b752fb937 100644 --- a/hr_timesheet_sheet/__manifest__.py +++ b/hr_timesheet_sheet/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'HR Timesheet Sheet', - 'version': '11.0.1.2.0', + 'version': '11.0.1.2.1', 'category': 'Human Resources', 'sequence': 80, 'summary': 'Timesheet Sheets, Activities', diff --git a/hr_timesheet_sheet/models/hr_timesheet_sheet.py b/hr_timesheet_sheet/models/hr_timesheet_sheet.py index 6c56b10c7..12439f4d4 100644 --- a/hr_timesheet_sheet/models/hr_timesheet_sheet.py +++ b/hr_timesheet_sheet/models/hr_timesheet_sheet.py @@ -370,6 +370,10 @@ def action_timesheet_done(self): raise UserError(_("Cannot approve a non-submitted sheet.")) self.write({'state': 'done'}) + @api.multi + def action_timesheet_refuse(self): + return self.action_timesheet_draft() + @api.multi def button_add_line(self): for rec in self: diff --git a/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py b/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py index aba7a1015..951315134 100644 --- a/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py +++ b/hr_timesheet_sheet/tests/test_hr_timesheet_sheet.py @@ -463,3 +463,29 @@ def test_8(self): sheet.add_line_project_id = project_3 with self.assertRaises(ValidationError): sheet.add_line_task_id = task_3 + + def test_9(self): + sheet = self.sheet_model.sudo(self.user).create({ + 'employee_id': self.employee.id, + 'company_id': self.user.company_id.id, + 'department_id': self.department.id, + }) + + sheet.add_line_project_id = self.project_1 + sheet.onchange_add_project_id() + sheet.sudo(self.user).button_add_line() + sheet._onchange_dates_or_timesheets() + sheet.onchange_add_project_id() + self.assertEqual(len(sheet.timesheet_ids), 1) + + sheet.action_timesheet_confirm() + self.assertEqual(sheet.state, 'confirm') + + sheet.action_timesheet_done() + self.assertEqual(sheet.state, 'done') + with self.assertRaises(UserError): + sheet.unlink() + + sheet.action_timesheet_refuse() + self.assertEqual(sheet.state, 'draft') + sheet.unlink() diff --git a/hr_timesheet_sheet/views/hr_timesheet_sheet_views.xml b/hr_timesheet_sheet/views/hr_timesheet_sheet_views.xml index cb2f4c18d..59d828e02 100644 --- a/hr_timesheet_sheet/views/hr_timesheet_sheet_views.xml +++ b/hr_timesheet_sheet/views/hr_timesheet_sheet_views.xml @@ -27,7 +27,7 @@