diff --git a/hr_timesheet_overtime_rate_holidays/__manifest__.py b/hr_timesheet_overtime_rate_holidays/__manifest__.py index 2674bb7..8f66ee6 100644 --- a/hr_timesheet_overtime_rate_holidays/__manifest__.py +++ b/hr_timesheet_overtime_rate_holidays/__manifest__.py @@ -5,15 +5,15 @@ { "name": "Timesheet - Overtime and holidays compatibility", "summary": "Don't apply overtime rates on timesheet lines created from a holiday", - "version": "16.0.1.0.0", + "version": "12.0.1.0.0", "category": "Human Resources", - "website": "https://github.com/coopiteasy/cie-timesheet", + "website": "https://coopiteasy.be", "author": "Coop IT Easy SC", "maintainers": ["carmenbianca"], "license": "AGPL-3", "depends": [ "project_timesheet_holidays", - "hr_timesheet_overtime_rate", + "hr_timesheet_overtime", ], "auto_install": True, } diff --git a/hr_timesheet_overtime_rate_holidays/models/account_analytic_line.py b/hr_timesheet_overtime_rate_holidays/models/account_analytic_line.py index 6cdffdc..f2825e3 100644 --- a/hr_timesheet_overtime_rate_holidays/models/account_analytic_line.py +++ b/hr_timesheet_overtime_rate_holidays/models/account_analytic_line.py @@ -8,8 +8,7 @@ class AnalyticLine(models.Model): _inherit = "account.analytic.line" - def get_overtime_rate(self): - self.ensure_one() - if self.holiday_id: - return 1 - return super().get_overtime_rate() + def _update_values(self, values): + if not values.get("holiday_id", self.holiday_id): + return super()._update_values(values) + return diff --git a/hr_timesheet_overtime_rate_holidays/tests/test_timesheet_holidays.py b/hr_timesheet_overtime_rate_holidays/tests/test_timesheet_holidays.py index e7eaa2b..cc9740f 100644 --- a/hr_timesheet_overtime_rate_holidays/tests/test_timesheet_holidays.py +++ b/hr_timesheet_overtime_rate_holidays/tests/test_timesheet_holidays.py @@ -17,13 +17,14 @@ def setUp(self): self.leave_start_datetime = datetime(2018, 2, 5, 7, 0, 0, 0) # this is monday self.leave_end_datetime = self.leave_start_datetime + relativedelta(days=3) - self.internal_project = self.env.company.internal_project_id - self.internal_task_leaves = self.env.company.leave_timesheet_task_id + self.internal_project = self.env.user.company_id.leave_timesheet_project_id + self.internal_task_leaves = self.env.user.company_id.leave_timesheet_task_id self.hr_leave_type = self.env["hr.leave.type"].create( { "name": "Leave Type", - "requires_allocation": "no", + "allocation_type": "no", + "validity_start": self.leave_start_datetime, "timesheet_generate": True, "timesheet_project_id": self.internal_project.id, "timesheet_task_id": self.internal_task_leaves.id, @@ -41,11 +42,23 @@ def setUp(self): } ) + # This is necessary because hr_timesheet_overtime depends on + # resource_work_time_from_contracts. + self.env["hr.contract"].create( + { + "name": "test", + "employee_id": self.empl_employee.id, + "wage": 0.0, + "resource_calendar_id": self.empl_employee.resource_calendar_id.id, + "date_start": "2017-01-01", + } + ) + def test_unit_amount(self): number_of_days = (self.leave_end_datetime - self.leave_start_datetime).days holiday = ( self.env["hr.leave"] - .with_user(self.user_employee) + .sudo(self.user_employee.id) .create( { "name": "Leave 1",