diff --git a/helpdesk_timesheet_time_type_non_billable/README.rst b/helpdesk_timesheet_time_type_non_billable/README.rst new file mode 100644 index 0000000000..47d14ca67d --- /dev/null +++ b/helpdesk_timesheet_time_type_non_billable/README.rst @@ -0,0 +1,98 @@ +========================================= +Helpdesk Timesheet Time Type Non Billable +========================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:f6a6b2f011c90e724385d1023afb84215d8e915fc87206a9c377154f96f7a37a + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Fhelpdesk-lightgray.png?logo=github + :target: https://github.com/OCA/helpdesk/tree/17.0/helpdesk_timesheet_time_type_non_billable + :alt: OCA/helpdesk +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/helpdesk-17-0/helpdesk-17-0-helpdesk_timesheet_time_type_non_billable + :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/helpdesk&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of hr_timesheet_type_non_billable +so that non-billable hours from helpdesk tickets are also excluded. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +1. Go to Project > Configuration > Time Type +2. Create or edit a Time Type and mark it as Non Billable +3. Go to Helpdesk -> Select one ticket +4. Select a project on the ticket +5. Create a new timesheet with the Time Type you just created +6. You will see that the time you entered on the timesheet is not + discounted on the remaining hours or added in total hours + +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 +------- + +* APSL-Nagarro + +Contributors +------------ + +[APSL-Nagarro](https://apsl.tech): + +- Miquel Pascual López + +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. + +.. |maintainer-mpascuall| image:: https://github.com/mpascuall.png?size=40px + :target: https://github.com/mpascuall + :alt: mpascuall + +Current `maintainer `__: + +|maintainer-mpascuall| + +This module is part of the `OCA/helpdesk `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/helpdesk_timesheet_time_type_non_billable/__init__.py b/helpdesk_timesheet_time_type_non_billable/__init__.py new file mode 100644 index 0000000000..abc2fc499a --- /dev/null +++ b/helpdesk_timesheet_time_type_non_billable/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2025 Miquel Pascual López(APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import models diff --git a/helpdesk_timesheet_time_type_non_billable/__manifest__.py b/helpdesk_timesheet_time_type_non_billable/__manifest__.py new file mode 100644 index 0000000000..0ccbc97dfb --- /dev/null +++ b/helpdesk_timesheet_time_type_non_billable/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2025 Miquel Pascual López(APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +{ + "name": "Helpdesk Timesheet Time Type Non Billable", + "version": "17.0.1.0.0", + "category": "Helpdesk", + "website": "https://github.com/OCA/helpdesk", + "author": "APSL-Nagarro, Odoo Community Association (OCA)", + "maintainers": ["mpascuall"], + "license": "AGPL-3", + "application": False, + "installable": True, + "depends": [ + "helpdesk_mgmt_timesheet", + "helpdesk_timesheet_time_type", + "hr_timesheet_type_non_billable", + ], +} diff --git a/helpdesk_timesheet_time_type_non_billable/models/__init__.py b/helpdesk_timesheet_time_type_non_billable/models/__init__.py new file mode 100644 index 0000000000..2ee99fef45 --- /dev/null +++ b/helpdesk_timesheet_time_type_non_billable/models/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2025 Miquel Pascual López(APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import helpdesk_ticket diff --git a/helpdesk_timesheet_time_type_non_billable/models/helpdesk_ticket.py b/helpdesk_timesheet_time_type_non_billable/models/helpdesk_ticket.py new file mode 100644 index 0000000000..93df42b72c --- /dev/null +++ b/helpdesk_timesheet_time_type_non_billable/models/helpdesk_ticket.py @@ -0,0 +1,17 @@ +# Copyright 2025 Miquel Pascual López(APSL-Nagarro) +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, models + + +class HelpdeskTicket(models.Model): + _inherit = "helpdesk.ticket" + + @api.depends("timesheet_ids.unit_amount", "timesheet_ids.time_type_id.non_billable") + def _compute_total_hours(self): + for record in self: + record.total_hours = sum( + line.unit_amount + for line in record.timesheet_ids + if not line.time_type_id.non_billable + ) diff --git a/helpdesk_timesheet_time_type_non_billable/pyproject.toml b/helpdesk_timesheet_time_type_non_billable/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/helpdesk_timesheet_time_type_non_billable/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/helpdesk_timesheet_time_type_non_billable/readme/CONTRIBUTORS.md b/helpdesk_timesheet_time_type_non_billable/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..ede77a0fb4 --- /dev/null +++ b/helpdesk_timesheet_time_type_non_billable/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +\[APSL-Nagarro\](): + - Miquel Pascual López \<\> \ No newline at end of file diff --git a/helpdesk_timesheet_time_type_non_billable/readme/DESCRIPTION.md b/helpdesk_timesheet_time_type_non_billable/readme/DESCRIPTION.md new file mode 100644 index 0000000000..2a8ffe32df --- /dev/null +++ b/helpdesk_timesheet_time_type_non_billable/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module extends the functionality of hr_timesheet_type_non_billable so that non-billable hours from helpdesk tickets are also excluded. \ No newline at end of file diff --git a/helpdesk_timesheet_time_type_non_billable/readme/USAGE.md b/helpdesk_timesheet_time_type_non_billable/readme/USAGE.md new file mode 100644 index 0000000000..aa71a0679e --- /dev/null +++ b/helpdesk_timesheet_time_type_non_billable/readme/USAGE.md @@ -0,0 +1,6 @@ +1. Go to Project > Configuration > Time Type +2. Create or edit a Time Type and mark it as Non Billable +3. Go to Helpdesk -> Select one ticket +4. Select a project on the ticket +5. Create a new timesheet with the Time Type you just created +5. You will see that the time you entered on the timesheet is not discounted on the remaining hours or added in total hours \ No newline at end of file diff --git a/helpdesk_timesheet_time_type_non_billable/static/description/index.html b/helpdesk_timesheet_time_type_non_billable/static/description/index.html new file mode 100644 index 0000000000..15f3cc677e --- /dev/null +++ b/helpdesk_timesheet_time_type_non_billable/static/description/index.html @@ -0,0 +1,440 @@ + + + + + +Helpdesk Timesheet Time Type Non Billable + + + +
+

Helpdesk Timesheet Time Type Non Billable

+ + +

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

+

This module extends the functionality of hr_timesheet_type_non_billable +so that non-billable hours from helpdesk tickets are also excluded.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Project > Configuration > Time Type
  2. +
  3. Create or edit a Time Type and mark it as Non Billable
  4. +
  5. Go to Helpdesk -> Select one ticket
  6. +
  7. Select a project on the ticket
  8. +
  9. Create a new timesheet with the Time Type you just created
  10. +
  11. You will see that the time you entered on the timesheet is not +discounted on the remaining hours or added in total hours
  12. +
+
+
+

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

+
    +
  • APSL-Nagarro
  • +
+
+
+

Contributors

+

[APSL-Nagarro](https://apsl.tech):

+ +
+
+

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.

+

Current maintainer:

+

mpascuall

+

This module is part of the OCA/helpdesk project on GitHub.

+

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

+
+
+
+ + diff --git a/helpdesk_timesheet_time_type_non_billable/tests/test_helpdesk_timesheet_time_type_non_billable.py b/helpdesk_timesheet_time_type_non_billable/tests/test_helpdesk_timesheet_time_type_non_billable.py new file mode 100644 index 0000000000..ec63ad0c9a --- /dev/null +++ b/helpdesk_timesheet_time_type_non_billable/tests/test_helpdesk_timesheet_time_type_non_billable.py @@ -0,0 +1,74 @@ +from odoo.tests.common import TransactionCase + + +class TestHrTimesheetTypeNonBillable(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.employee = cls.env["hr.employee"].create( + { + "name": "Test Employee", + } + ) + cls.project = cls.env["project.project"].create( + { + "name": "Test Project", + "allocated_hours": 50, + } + ) + cls.billable_type = cls.env["project.time.type"].create( + { + "name": "Billable", + "non_billable": False, + } + ) + cls.non_billable_type = cls.env["project.time.type"].create( + { + "name": "Non-Billable", + "non_billable": True, + } + ) + cls.ticket = cls.env["helpdesk.ticket"].create( + { + "name": "Test Ticket", + "project_id": cls.project.id, + "planned_hours": 8, + "description": "Test Helpdesk Ticket", + } + ) + + def test_helpdesk_ticket_non_billable_timesheet(self): + self.env["account.analytic.line"].create( + { + "employee_id": self.employee.id, + "name": "Non-Billable Helpdesk Timesheet", + "project_id": self.project.id, + "ticket_id": self.ticket.id, + "unit_amount": 1, + "time_type_id": self.non_billable_type.id, + } + ) + + self.env["account.analytic.line"].create( + { + "employee_id": self.employee.id, + "name": "Billable Helpdesk Timesheet", + "project_id": self.project.id, + "ticket_id": self.ticket.id, + "unit_amount": 2, + "time_type_id": self.billable_type.id, + } + ) + + self.assertEqual( + self.ticket.total_hours, + 2, + "Helpdesk ticket total hours should exclude non-billable timesheets.", + ) + + self.assertEqual( + self.ticket.remaining_hours, + 6, + "Helpdesk ticket effective hours should only include billable timesheets.", + )