Skip to content

Commit

Permalink
[MIG] hr_timesheet_overtime_rate_holidays: Migrate to 12.0
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
  • Loading branch information
carmenbianca committed Oct 11, 2024
1 parent bef21de commit 94fd511
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
6 changes: 3 additions & 3 deletions hr_timesheet_overtime_rate_holidays/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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",
Expand Down

0 comments on commit 94fd511

Please sign in to comment.