diff --git a/hr_payroll_attendance_report/README.rst b/hr_payroll_attendance_report/README.rst new file mode 100644 index 000000000..f9206707a --- /dev/null +++ b/hr_payroll_attendance_report/README.rst @@ -0,0 +1,78 @@ +========================= +Payroll Attendance Report +========================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:feeb4c350afe5ddb6efb4be0891f8a31c814abb0f3aa92d9b67b4c19476314ca + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpayroll-lightgray.png?logo=github + :target: https://github.com/OCA/payroll/tree/16.0/hr_payroll_attendance_report + :alt: OCA/payroll +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/payroll-16-0/payroll-16-0-hr_payroll_attendance_report + :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/payroll&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Attendance Control on Payslip + +**Table of contents** + +.. contents:: + :local: + +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 +~~~~~~~ + +* Escodoo + +Contributors +~~~~~~~~~~~~ + +* `Escodoo `_: + + * Cristiano Mafra Junior + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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/payroll `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/hr_payroll_attendance_report/__init__.py b/hr_payroll_attendance_report/__init__.py new file mode 100644 index 000000000..ed65565dc --- /dev/null +++ b/hr_payroll_attendance_report/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2025 - TODAY, Cristiano Mafra Junior +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import models diff --git a/hr_payroll_attendance_report/__manifest__.py b/hr_payroll_attendance_report/__manifest__.py new file mode 100644 index 000000000..1580f67f4 --- /dev/null +++ b/hr_payroll_attendance_report/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2025 - TODAY, Cristiano Mafra Junior +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Payroll Attendance Report", + "summary": "Payslip Attendance on Report", + "version": "16.0.1.0.0", + "author": "Escodoo ,Odoo Community Association (OCA)", + "license": "AGPL-3", + "website": "https://github.com/OCA/payroll", + "depends": [ + "payroll", + "hr_attendance", + ], + "data": [ + "report/report_hr_payroll_attendance.xml", + ], + "installable": True, +} diff --git a/hr_payroll_attendance_report/i18n/hr_payroll_attendance_report.pot b/hr_payroll_attendance_report/i18n/hr_payroll_attendance_report.pot new file mode 100644 index 000000000..f0381267f --- /dev/null +++ b/hr_payroll_attendance_report/i18n/hr_payroll_attendance_report.pot @@ -0,0 +1,61 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * hr_payroll_attendance_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-09-24 12:54+0000\n" +"PO-Revision-Date: 2025-09-24 12:54+0000\n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: hr_payroll_attendance_report +#: model_terms:ir.ui.view,arch_db:hr_payroll_attendance_report.report_hr_payroll_attendance_report +msgid "Total in Period:" +msgstr "" + +#. module: hr_payroll_attendance_report +#: model:ir.model.fields,field_description:hr_payroll_attendance_report.field_hr_payslip__attendance_ids +msgid "Attendance" +msgstr "" + +#. module: hr_payroll_attendance_report +#: model_terms:ir.ui.view,arch_db:hr_payroll_attendance_report.report_hr_payroll_attendance_report +msgid "Check In" +msgstr "" + +#. module: hr_payroll_attendance_report +#: model_terms:ir.ui.view,arch_db:hr_payroll_attendance_report.report_hr_payroll_attendance_report +msgid "Check Out" +msgstr "" + +#. module: hr_payroll_attendance_report +#: model_terms:ir.ui.view,arch_db:hr_payroll_attendance_report.report_hr_payroll_attendance_report +msgid "Date" +msgstr "" + +#. module: hr_payroll_attendance_report +#: model:ir.model,name:hr_payroll_attendance_report.model_hr_payslip +msgid "Payslip" +msgstr "" + +#. module: hr_payroll_attendance_report +#: model_terms:ir.ui.view,arch_db:hr_payroll_attendance_report.report_hr_payroll_attendance_report +msgid "Total" +msgstr "" + +#. module: hr_payroll_attendance_report +#: model:ir.model.fields,field_description:hr_payroll_attendance_report.field_hr_payslip__total_worked_hours +msgid "Total Worked Hours" +msgstr "" + +#. module: hr_payroll_attendance_report +#: model_terms:ir.ui.view,arch_db:hr_payroll_attendance_report.report_hr_payroll_attendance_report +msgid "Worked Hours" +msgstr "" diff --git a/hr_payroll_attendance_report/models/__init__.py b/hr_payroll_attendance_report/models/__init__.py new file mode 100644 index 000000000..47c74fb36 --- /dev/null +++ b/hr_payroll_attendance_report/models/__init__.py @@ -0,0 +1,3 @@ +# Copyright 2025 - TODAY, Cristiano Mafra Junior +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import hr_payslip diff --git a/hr_payroll_attendance_report/models/hr_payslip.py b/hr_payroll_attendance_report/models/hr_payslip.py new file mode 100644 index 000000000..622be458a --- /dev/null +++ b/hr_payroll_attendance_report/models/hr_payslip.py @@ -0,0 +1,30 @@ +# Copyright 2025 - TODAY, Cristiano Mafra Junior +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class HrPayslip(models.Model): + _inherit = "hr.payslip" + + attendance_ids = fields.One2many( + comodel_name="hr.attendance", + compute="_compute_attendance_ids", + ) + total_worked_hours = fields.Float( + compute="_compute_attendance_ids", + ) + + @api.depends("date_from", "date_to", "employee_id") + def _compute_attendance_ids(self): + for slip in self: + attendances = self.env["hr.attendance"].search( + [ + ("employee_id", "=", slip.employee_id.id), + ("check_in", ">=", slip.date_from), + ("check_in", "<=", slip.date_to), + ], + order="check_in ASC", + ) + slip.attendance_ids = attendances + slip.total_worked_hours = sum(att.worked_hours for att in attendances) diff --git a/hr_payroll_attendance_report/pyproject.toml b/hr_payroll_attendance_report/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/hr_payroll_attendance_report/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/hr_payroll_attendance_report/readme/CONTRIBUTORS.rst b/hr_payroll_attendance_report/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..418948a9f --- /dev/null +++ b/hr_payroll_attendance_report/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* `Escodoo `_: + + * Cristiano Mafra Junior diff --git a/hr_payroll_attendance_report/readme/DESCRIPTION.rst b/hr_payroll_attendance_report/readme/DESCRIPTION.rst new file mode 100644 index 000000000..11060c6cc --- /dev/null +++ b/hr_payroll_attendance_report/readme/DESCRIPTION.rst @@ -0,0 +1 @@ +Attendance Control on Payslip diff --git a/hr_payroll_attendance_report/report/report_hr_payroll_attendance.xml b/hr_payroll_attendance_report/report/report_hr_payroll_attendance.xml new file mode 100644 index 000000000..36028d243 --- /dev/null +++ b/hr_payroll_attendance_report/report/report_hr_payroll_attendance.xml @@ -0,0 +1,66 @@ + + + + + diff --git a/hr_payroll_attendance_report/static/description/icon.png b/hr_payroll_attendance_report/static/description/icon.png new file mode 100644 index 000000000..12ab0051e Binary files /dev/null and b/hr_payroll_attendance_report/static/description/icon.png differ diff --git a/hr_payroll_attendance_report/static/description/index.html b/hr_payroll_attendance_report/static/description/index.html new file mode 100644 index 000000000..3bf151575 --- /dev/null +++ b/hr_payroll_attendance_report/static/description/index.html @@ -0,0 +1,423 @@ + + + + + +Payroll Attendance Report + + + +
+

Payroll Attendance Report

+ + +

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

+

Attendance Control on Payslip

+

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

+
    +
  • Escodoo
  • +
+
+
+

Contributors

+ +
+
+

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/payroll project on GitHub.

+

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

+
+
+
+ + diff --git a/hr_payroll_attendance_report/tests/__init__.py b/hr_payroll_attendance_report/tests/__init__.py new file mode 100644 index 000000000..4ce111d26 --- /dev/null +++ b/hr_payroll_attendance_report/tests/__init__.py @@ -0,0 +1 @@ +from . import test_attendance_on_payslip diff --git a/hr_payroll_attendance_report/tests/test_attendance_on_payslip.py b/hr_payroll_attendance_report/tests/test_attendance_on_payslip.py new file mode 100644 index 000000000..3c65bd55e --- /dev/null +++ b/hr_payroll_attendance_report/tests/test_attendance_on_payslip.py @@ -0,0 +1,66 @@ +# Copyright 2025 - TODAY, Cristiano Mafra Junior +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from datetime import datetime, timedelta + +from odoo.tests.common import TransactionCase + + +class TestPayrollAttendanceReport(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True)) + cls.employee = cls.env["hr.employee"].create( + { + "name": "Test Employee", + } + ) + cls.contract = cls.env["hr.contract"].create( + { + "name": "Contract", + "employee_id": cls.employee.id, + "date_start": datetime(2025, 1, 1), + "wage": 1000, + "state": "open", + } + ) + cls.date_from = datetime(2025, 1, 1) + cls.date_to = datetime(2025, 1, 31) + + cls.payslip = cls.env["hr.payslip"].create( + { + "employee_id": cls.employee.id, + "date_from": cls.date_from, + "date_to": cls.date_to, + "contract_id": cls.contract.id, + } + ) + cls.env["hr.attendance"].create( + { + "employee_id": cls.employee.id, + "check_in": datetime(2025, 1, 10, 9, 0, 0), + "check_out": datetime(2025, 1, 10, 17, 0, 0), + } + ) + cls.env["hr.attendance"].create( + { + "employee_id": cls.employee.id, + "check_in": datetime(2025, 1, 15, 9, 0, 0), + "check_out": datetime(2025, 1, 15, 13, 0, 0), + } + ) + + def test_attendance_links_and_totals(self): + self.payslip.compute_sheet() + slip = self.payslip.with_context(prefetch_fields=False) + self.assertTrue(hasattr(slip, "attendance_ids")) + self.assertTrue(hasattr(slip, "total_worked_hours")) + + self.assertEqual(len(slip.attendance_ids), 2) + + self.assertAlmostEqual(slip.total_worked_hours, 12.0, places=2) + + for att in slip.attendance_ids: + self.assertGreaterEqual(att.check_in, self.date_from) + self.assertLessEqual(att.check_out, self.date_to + timedelta(days=1)) diff --git a/setup/hr_payroll_attendance_report/odoo/addons/hr_payroll_attendance_report b/setup/hr_payroll_attendance_report/odoo/addons/hr_payroll_attendance_report new file mode 120000 index 000000000..a527f17c1 --- /dev/null +++ b/setup/hr_payroll_attendance_report/odoo/addons/hr_payroll_attendance_report @@ -0,0 +1 @@ +../../../../hr_payroll_attendance_report \ No newline at end of file diff --git a/setup/hr_payroll_attendance_report/setup.py b/setup/hr_payroll_attendance_report/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/hr_payroll_attendance_report/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)