-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from hbrunn/15.0-83-delete_resource_leaves
[FIX] remove resource leaves when resetting to draft
- Loading branch information
Showing
8 changed files
with
137 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="verdigado_manager_employee" model="hr.employee"> | ||
<field name="name">Verdigado manager</field> | ||
<field name="user_id" ref="verdigado_manager" /> | ||
</record> | ||
<record id="verdigado_officer_employee" model="hr.employee"> | ||
<field name="name">Verdigado officer</field> | ||
<field name="user_id" ref="verdigado_officer" /> | ||
<field name="parent_id" ref="verdigado_manager_employee" /> | ||
</record> | ||
<record id="verdigado_user_employee" model="hr.employee"> | ||
<field name="name">Verdigado user</field> | ||
<field name="user_id" ref="verdigado_user" /> | ||
<field name="parent_id" ref="verdigado_officer_employee" /> | ||
</record> | ||
</odoo> |
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,21 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="allocation_user_2023" model="hr.leave.allocation"> | ||
<field name="name">Paid Time Off for Verdigado employee 2023</field> | ||
<field name="holiday_status_id" ref="hr_holidays.holiday_status_cl" /> | ||
<field name="number_of_days">30</field> | ||
<field name="employee_id" ref="verdigado_user_employee" /> | ||
<field name="state">validate</field> | ||
<field name="date_from">2023-01-01</field> | ||
<field name="date_to">2023-12-31</field> | ||
</record> | ||
<record id="allocation_user_2042" model="hr.leave.allocation"> | ||
<field name="name">Paid Time Off for Verdigado employee 2042</field> | ||
<field name="holiday_status_id" ref="hr_holidays.holiday_status_cl" /> | ||
<field name="number_of_days">30</field> | ||
<field name="employee_id" ref="verdigado_user_employee" /> | ||
<field name="state">validate</field> | ||
<field name="date_from">2042-01-01</field> | ||
<field name="date_to">2042-12-31</field> | ||
</record> | ||
</odoo> |
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
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,13 @@ | ||
# Copyright 2023 Hunki Enterprises BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo.tests.common import TransactionCase | ||
|
||
|
||
class HrCase(TransactionCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
cls.verdigado_user = cls.env.ref("verdigado_attendance.verdigado_user") | ||
cls.verdigado_officer = cls.env.ref("verdigado_attendance.verdigado_officer") | ||
cls.verdigado_manager = cls.env.ref("verdigado_attendance.verdigado_manager") |
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,77 @@ | ||
# Copyright 2023 Hunki Enterprises BV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import exceptions | ||
|
||
from .hr_case import HrCase | ||
|
||
|
||
class TestHolidays(HrCase): | ||
def test_standard_flow_past(self): | ||
"""Test that employees can request holidays for the past""" | ||
holiday = ( | ||
self.env["hr.leave"] | ||
.with_user(self.verdigado_user) | ||
.create( | ||
{ | ||
"employee_id": self.verdigado_user.employee_id.id, | ||
"holiday_status_id": self.env.ref( | ||
"hr_holidays.holiday_status_cl" | ||
).id, | ||
"date_from": "2023-12-11 07:00:00", | ||
"date_to": "2023-12-13 16:00:00", | ||
} | ||
) | ||
) | ||
holiday_status = holiday.holiday_status_id | ||
with self.assertRaisesRegex( | ||
exceptions.UserError, | ||
"manager rights to modify/validate a time off that already begun", | ||
): | ||
holiday.action_approve() | ||
holiday_as_officer = holiday.with_user(self.verdigado_officer) | ||
holiday_as_officer.action_validate() | ||
self.assertEqual(holiday.number_of_days, 3) | ||
self.assertEqual(holiday_status.remaining_leaves, 27) | ||
resource_leave = self.env["resource.calendar.leaves"].search( | ||
[("holiday_id", "in", holiday.ids)] | ||
) | ||
self.assertTrue(resource_leave) | ||
with self.assertRaisesRegex( | ||
exceptions.UserError, | ||
"manager rights to modify/validate a time off that already begun", | ||
): | ||
holiday.unlink() | ||
holiday_as_officer.unlink() | ||
self.assertFalse(resource_leave.exists()) | ||
self.assertEqual(holiday_status.remaining_leaves, 30) | ||
|
||
def test_standard_flow_future(self): | ||
"""Test that employees can request holidays for the future""" | ||
holiday = ( | ||
self.env["hr.leave"] | ||
.with_user(self.verdigado_user) | ||
.create( | ||
{ | ||
"employee_id": self.verdigado_user.employee_id.id, | ||
"holiday_status_id": self.env.ref( | ||
"hr_holidays.holiday_status_cl" | ||
).id, | ||
"date_from": "2042-12-15 07:00:00", | ||
"date_to": "2042-12-17 16:00:00", | ||
} | ||
) | ||
) | ||
holiday_status = holiday.holiday_status_id | ||
with self.assertRaisesRegex( | ||
exceptions.UserError, "approve/refuse its own requests" | ||
): | ||
holiday.action_approve() | ||
holiday_as_officer = holiday.with_user(self.verdigado_officer) | ||
holiday_as_officer.action_validate() | ||
resource_leave = self.env["resource.calendar.leaves"].search( | ||
[("holiday_id", "in", holiday.ids)] | ||
) | ||
self.assertTrue(resource_leave) | ||
holiday.unlink() | ||
self.assertEqual(holiday_status.remaining_leaves, 30) |