From 3257f11842cee90358ec7c714c9ccc3bad880cbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Duy=20=28=C4=90=E1=BB=97=20Anh=29?= Date: Mon, 12 Aug 2024 11:25:32 +0700 Subject: [PATCH] [MOV] hr_attendance_overtime_nagative_hours: rename to hr_leave_dashboard_extra_time --- .../readme/DESCRIPTION.md | 1 - .../static/description/index.html | 30 -- .../README.rst | 19 +- .../__init__.py | 0 .../__manifest__.py | 7 +- .../images/screen.png | Bin .../models/__init__.py | 0 .../models/hr_leave_type.py | 2 +- .../pyproject.toml | 0 .../readme/CONTRIBUTORS.md | 0 .../readme/CREDITS.md | 0 .../readme/DESCRIPTION.md | 1 + .../static/description/icon.png | Bin .../static/description/index.html | 435 ++++++++++++++++++ .../tests/__init__.py | 1 + .../test_hr_leave_dashboard_extra_time.py | 84 ++++ 16 files changed, 538 insertions(+), 42 deletions(-) delete mode 100644 hr_attendance_overtime_negative_hours/readme/DESCRIPTION.md delete mode 100644 hr_attendance_overtime_negative_hours/static/description/index.html rename {hr_attendance_overtime_negative_hours => hr_leave_dashboard_extra_time}/README.rst (78%) rename {hr_attendance_overtime_negative_hours => hr_leave_dashboard_extra_time}/__init__.py (100%) rename {hr_attendance_overtime_negative_hours => hr_leave_dashboard_extra_time}/__manifest__.py (64%) rename {hr_attendance_overtime_negative_hours => hr_leave_dashboard_extra_time}/images/screen.png (100%) rename {hr_attendance_overtime_negative_hours => hr_leave_dashboard_extra_time}/models/__init__.py (100%) rename {hr_attendance_overtime_negative_hours => hr_leave_dashboard_extra_time}/models/hr_leave_type.py (99%) rename {hr_attendance_overtime_negative_hours => hr_leave_dashboard_extra_time}/pyproject.toml (100%) rename {hr_attendance_overtime_negative_hours => hr_leave_dashboard_extra_time}/readme/CONTRIBUTORS.md (100%) rename {hr_attendance_overtime_negative_hours => hr_leave_dashboard_extra_time}/readme/CREDITS.md (100%) create mode 100644 hr_leave_dashboard_extra_time/readme/DESCRIPTION.md rename {hr_attendance_overtime_negative_hours => hr_leave_dashboard_extra_time}/static/description/icon.png (100%) create mode 100644 hr_leave_dashboard_extra_time/static/description/index.html create mode 100644 hr_leave_dashboard_extra_time/tests/__init__.py create mode 100644 hr_leave_dashboard_extra_time/tests/test_hr_leave_dashboard_extra_time.py diff --git a/hr_attendance_overtime_negative_hours/readme/DESCRIPTION.md b/hr_attendance_overtime_negative_hours/readme/DESCRIPTION.md deleted file mode 100644 index c780ecd2..00000000 --- a/hr_attendance_overtime_negative_hours/readme/DESCRIPTION.md +++ /dev/null @@ -1 +0,0 @@ -Show Negative Hours in Leaves overview (TimeOffCalendar widget) diff --git a/hr_attendance_overtime_negative_hours/static/description/index.html b/hr_attendance_overtime_negative_hours/static/description/index.html deleted file mode 100644 index c654ee08..00000000 --- a/hr_attendance_overtime_negative_hours/static/description/index.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - License: GPL-3 - -
-

HR Attendance Overtime Negative Hours

-

Show negative hours in leave overview.

-

For a detailed documentation have a look at https://www.odoo-wiki.org/.

- Icon -
-

Configuration

-
    -
  • No additional configurations needed
  • -
-
-

Maintainer

- - - -

This module is maintained by Mint System GmbH.

-

For support and more information, please visit our Website.

-
-
-
- - \ No newline at end of file diff --git a/hr_attendance_overtime_negative_hours/README.rst b/hr_leave_dashboard_extra_time/README.rst similarity index 78% rename from hr_attendance_overtime_negative_hours/README.rst rename to hr_leave_dashboard_extra_time/README.rst index 7f027de1..a097cc8c 100644 --- a/hr_attendance_overtime_negative_hours/README.rst +++ b/hr_leave_dashboard_extra_time/README.rst @@ -1,6 +1,6 @@ -===================================== -HR Attendance Overtime Negative Hours -===================================== +============================= +HR Leave Dashboard Extra Time +============================= .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -17,10 +17,10 @@ HR Attendance Overtime Negative Hours :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--attendance-lightgray.png?logo=github - :target: https://github.com/OCA/hr-attendance/tree/17.0/hr_attendance_overtime_negative_hours + :target: https://github.com/OCA/hr-attendance/tree/17.0/hr_leave_dashboard_extra_time :alt: OCA/hr-attendance .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/hr-attendance-17-0/hr-attendance-17-0-hr_attendance_overtime_negative_hours + :target: https://translation.odoo-community.org/projects/hr-attendance-17-0/hr-attendance-17-0-hr_leave_dashboard_extra_time :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png :target: https://runboat.odoo-community.org/builds?repo=OCA/hr-attendance&target_branch=17.0 @@ -28,7 +28,10 @@ HR Attendance Overtime Negative Hours |badge1| |badge2| |badge3| |badge4| |badge5| -Show Negative Hours in Leaves overview (TimeOffCalendar widget) +Display an additional card at the top of the Time Off Dashboard: Extra +Hours, informing the employee about the number of extra hours he has +been working and thus the number of hours available for him to take as a +compensation leave. **Table of contents** @@ -41,7 +44,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -81,6 +84,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/hr-attendance `_ project on GitHub. +This module is part of the `OCA/hr-attendance `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_attendance_overtime_negative_hours/__init__.py b/hr_leave_dashboard_extra_time/__init__.py similarity index 100% rename from hr_attendance_overtime_negative_hours/__init__.py rename to hr_leave_dashboard_extra_time/__init__.py diff --git a/hr_attendance_overtime_negative_hours/__manifest__.py b/hr_leave_dashboard_extra_time/__manifest__.py similarity index 64% rename from hr_attendance_overtime_negative_hours/__manifest__.py rename to hr_leave_dashboard_extra_time/__manifest__.py index 7b3bd6da..955ec4ec 100644 --- a/hr_attendance_overtime_negative_hours/__manifest__.py +++ b/hr_leave_dashboard_extra_time/__manifest__.py @@ -2,9 +2,12 @@ # Copyright 2024 Camptocamp # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - "name": "HR Attendance Overtime Negative Hours", + "name": "HR Leave Dashboard Extra Time", "summary": """ - Show negative hours in leave overview. + Display an additional card at the top of the Time Off Dashboard: + Extra Hours, informing the employee about the number of extra hours + he has been working and thus the number of hours available + for him to take as a compensation leave """, "author": "Mint System GmbH, Odoo Community Association (OCA)", "website": "https://github.com/OCA/hr-attendance", diff --git a/hr_attendance_overtime_negative_hours/images/screen.png b/hr_leave_dashboard_extra_time/images/screen.png similarity index 100% rename from hr_attendance_overtime_negative_hours/images/screen.png rename to hr_leave_dashboard_extra_time/images/screen.png diff --git a/hr_attendance_overtime_negative_hours/models/__init__.py b/hr_leave_dashboard_extra_time/models/__init__.py similarity index 100% rename from hr_attendance_overtime_negative_hours/models/__init__.py rename to hr_leave_dashboard_extra_time/models/__init__.py diff --git a/hr_attendance_overtime_negative_hours/models/hr_leave_type.py b/hr_leave_dashboard_extra_time/models/hr_leave_type.py similarity index 99% rename from hr_attendance_overtime_negative_hours/models/hr_leave_type.py rename to hr_leave_dashboard_extra_time/models/hr_leave_type.py index e2f1e364..59c7b73a 100644 --- a/hr_attendance_overtime_negative_hours/models/hr_leave_type.py +++ b/hr_leave_dashboard_extra_time/models/hr_leave_type.py @@ -93,9 +93,9 @@ def _prepare_extra_hours_data(self, employee, target_date): allocations_now = self.env["hr.leave.allocation"] allocations_date = self.env["hr.leave.allocation"] allocations_with_remaining_leaves = self.env["hr.leave.allocation"] + today = fields.Date.today() for allocation, data in allocations_leaves_consumed[employee][self].items(): if allocation: - today = fields.Date.today() if allocation.date_from <= today and ( not allocation.date_to or allocation.date_to >= today ): diff --git a/hr_attendance_overtime_negative_hours/pyproject.toml b/hr_leave_dashboard_extra_time/pyproject.toml similarity index 100% rename from hr_attendance_overtime_negative_hours/pyproject.toml rename to hr_leave_dashboard_extra_time/pyproject.toml diff --git a/hr_attendance_overtime_negative_hours/readme/CONTRIBUTORS.md b/hr_leave_dashboard_extra_time/readme/CONTRIBUTORS.md similarity index 100% rename from hr_attendance_overtime_negative_hours/readme/CONTRIBUTORS.md rename to hr_leave_dashboard_extra_time/readme/CONTRIBUTORS.md diff --git a/hr_attendance_overtime_negative_hours/readme/CREDITS.md b/hr_leave_dashboard_extra_time/readme/CREDITS.md similarity index 100% rename from hr_attendance_overtime_negative_hours/readme/CREDITS.md rename to hr_leave_dashboard_extra_time/readme/CREDITS.md diff --git a/hr_leave_dashboard_extra_time/readme/DESCRIPTION.md b/hr_leave_dashboard_extra_time/readme/DESCRIPTION.md new file mode 100644 index 00000000..69453913 --- /dev/null +++ b/hr_leave_dashboard_extra_time/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Display an additional card at the top of the Time Off Dashboard: Extra Hours, informing the employee about the number of extra hours he has been working and thus the number of hours available for him to take as a compensation leave. diff --git a/hr_attendance_overtime_negative_hours/static/description/icon.png b/hr_leave_dashboard_extra_time/static/description/icon.png similarity index 100% rename from hr_attendance_overtime_negative_hours/static/description/icon.png rename to hr_leave_dashboard_extra_time/static/description/icon.png diff --git a/hr_leave_dashboard_extra_time/static/description/index.html b/hr_leave_dashboard_extra_time/static/description/index.html new file mode 100644 index 00000000..ae10e63f --- /dev/null +++ b/hr_leave_dashboard_extra_time/static/description/index.html @@ -0,0 +1,435 @@ + + + + + +HR Leave Dashboard Extra Time + + + +
+

HR Leave Dashboard Extra Time

+ + +

Beta License: AGPL-3 OCA/hr-attendance Translate me on Weblate Try me on Runboat

+

Display an additional card at the top of the Time Off Dashboard: Extra +Hours, informing the employee about the number of extra hours he has +been working and thus the number of hours available for him to take as a +compensation leave.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Mint System GmbH
  • +
+
+
+

Contributors

+ +
+
+

Other credits

+

The original development of this module has been done by Mint System. It +can be found in: +https://github.com/Mint-System/Odoo-Apps-HR/blob/15.0/hr_attendance_overtime_negative_hours

+

This module has been ported to the OCA with their agreement.

+
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/hr-attendance project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/hr_leave_dashboard_extra_time/tests/__init__.py b/hr_leave_dashboard_extra_time/tests/__init__.py new file mode 100644 index 00000000..a0da2ab2 --- /dev/null +++ b/hr_leave_dashboard_extra_time/tests/__init__.py @@ -0,0 +1 @@ +from . import test_hr_leave_dashboard_extra_time diff --git a/hr_leave_dashboard_extra_time/tests/test_hr_leave_dashboard_extra_time.py b/hr_leave_dashboard_extra_time/tests/test_hr_leave_dashboard_extra_time.py new file mode 100644 index 00000000..0e59293d --- /dev/null +++ b/hr_leave_dashboard_extra_time/tests/test_hr_leave_dashboard_extra_time.py @@ -0,0 +1,84 @@ +# Copyright 2023 Janik von Rotz +# Copyright 2024 Camptocamp +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from datetime import date, datetime + +from odoo import fields +from odoo.tests.common import TransactionCase + + +class TestHrLeaveDashboardExtraTime(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.user_id = cls.env.user + cls.company = cls.env.company + cls.company.write( + { + "hr_attendance_overtime": True, + "overtime_start_date": date(2024, 5, 25), + } + ) + + cls.user_id.company_id = cls.company + cls.user_id.tz = "UTC" + cls.user_id.company_id.resource_calendar_id.tz = "UTC" + cls.extra_hours_leave_type = cls.env.ref( + "hr_holidays_attendance.holiday_status_extra_hours", + ) + cls.employee = cls.env["hr.employee"].create( + { + "name": "Test Employee", + "company_id": cls.company.id, + "user_id": cls.user_id.id, + } + ) + cls.env["hr.attendance"].create( + [ + { + "employee_id": cls.employee.id, + "check_in": datetime(2024, 5, 28, 8, 0), + "check_out": datetime(2024, 5, 28, 20, 0), + }, + { + "employee_id": cls.employee.id, + "check_in": datetime(2024, 5, 29, 8, 0), + "check_out": datetime(2024, 5, 29, 20, 0), + }, + { + "employee_id": cls.employee.id, + "check_in": datetime(2024, 5, 30, 8, 0), + "check_out": datetime(2024, 5, 30, 20, 0), + }, + { + "employee_id": cls.employee.id, + "check_in": datetime(2024, 5, 31, 8, 0), + "check_out": datetime(2024, 5, 31, 20, 0), + }, + ] + ) + context = cls.env.context.copy() + context["allowed_company_ids"] = [cls.company.id] + cls.env.context = context + + def test_get_allocation_data_request(self): + self.assertEqual(self.employee.total_overtime, 12) + leave = self.env["hr.leave"].create( + { + "request_date_from": date(2024, 5, 30), + "request_date_to": date(2024, 5, 30), + "employee_id": self.employee.id, + "holiday_status_id": self.extra_hours_leave_type.id, + } + ) + self.assertEqual(leave.number_of_hours_display, 8) + target_date = fields.Date.today() + result = self.extra_hours_leave_type.get_allocation_data_request(target_date) + self.assertEqual(result[0][0], self.extra_hours_leave_type.name) + self.assertEqual(result[0][2], "no") + self.assertEqual(result[0][3], self.extra_hours_leave_type.id) + lt_values = result[0][1] + self.assertEqual(lt_values["leaves_requested"], 1) + self.assertEqual(lt_values["leaves_taken"], 0) + self.assertEqual(lt_values["request_unit"], "hour")