-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] hr_holidays_remaining_leaves: Migration to 17.0
- Loading branch information
sonhd91
committed
Jun 17, 2024
1 parent
ac28cc7
commit c8b673c
Showing
7 changed files
with
99 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* Janik von Rotz <[email protected]> | ||
* Son Ho <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
The original development has been done development of this module has been done by Mint System. | ||
It can be found in: https://github.com/Mint-System/Odoo-Apps-HR/tree/16.0/hr_holidays_remaining_leaves | ||
|
||
This module has been ported to the OCA with their agreement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Show remaining leaves per employee in allocation overview. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_hr_holidays_remaining_leaves |
54 changes: 54 additions & 0 deletions
54
hr_holidays_remaining_leaves/tests/test_hr_holidays_remaining_leaves.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from freezegun import freeze_time | ||
|
||
from odoo.addons.hr_holidays.tests.test_allocations import TestAllocations | ||
|
||
|
||
class TestHrHolidaysRemainLeaves(TestAllocations): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
|
||
def test_hr_holidays_remaining_leaves(self): | ||
emp_allocation = self.env["hr.leave.allocation"].create( | ||
{ | ||
"name": "Bank Holiday", | ||
"holiday_type": "employee", | ||
"employee_ids": [(4, self.employee.id)], | ||
"employee_id": self.employee.id, | ||
"date_from": "2024-06-17", | ||
"holiday_status_id": self.leave_type.id, | ||
"number_of_days": 3, | ||
"allocation_type": "regular", | ||
} | ||
) | ||
emp_allocation.action_validate() | ||
with freeze_time("2024-06-19"): | ||
leave_current = self.env["hr.leave"].create( | ||
{ | ||
"holiday_status_id": self.leave_type.id, | ||
"employee_id": self.employee.id, | ||
"date_from": "2024-06-19", | ||
"date_to": "2024-06-19", | ||
} | ||
) | ||
leave_current.action_validate() | ||
with freeze_time("2024-06-25"): | ||
leave_fututre = self.env["hr.leave"].create( | ||
{ | ||
"holiday_status_id": self.leave_type.id, | ||
"employee_id": self.employee.id, | ||
"date_from": "2024-06-25", | ||
"date_to": "2024-06-25", | ||
} | ||
) | ||
leave_fututre.action_validate() | ||
|
||
with freeze_time("2024-06-23"): | ||
self.assertEqual(emp_allocation.remaining_leaves_days, 1.0) | ||
self.assertEqual(emp_allocation.remaining_leaves_hours, 8.0) | ||
self.assertEqual(emp_allocation.remaining_leaves_display, "1.0 days") | ||
self.assertEqual(emp_allocation.remaining_leaves_current_days, 2.0) | ||
self.assertEqual(emp_allocation.remaining_leaves_current_hours, 16.0) | ||
self.assertEqual( | ||
emp_allocation.remaining_leaves_current_display, "2.0 days" | ||
) |