diff --git a/project_timesheet_holidays_task_enable/README.rst b/project_timesheet_holidays_task_enable/README.rst new file mode 100644 index 000000000..11edeb540 --- /dev/null +++ b/project_timesheet_holidays_task_enable/README.rst @@ -0,0 +1,78 @@ +=========================================== +Project Timesheet Holidays - re-enable task +=========================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c73e37413db874026ad8fdce11c36806b9b5b0a83205f3a5708992fab9f95578 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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%2Ftimesheet-lightgray.png?logo=github + :target: https://github.com/OCA/timesheet/tree/18.0/project_timesheet_holidays_task_enable + :alt: OCA/timesheet +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/timesheet-18-0/timesheet-18-0-project_timesheet_holidays_task_enable + :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/timesheet&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +When a task is used in leave types configuration, it cannot be used +filling manual timesheets. With this addon, it's possible to re-enable a +task affected by this limitation. + +**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 +------- + +* Solvos Consultoría Informática + +Contributors +------------ + +- David ALonso + +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/timesheet `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/project_timesheet_holidays_task_enable/__init__.py b/project_timesheet_holidays_task_enable/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/project_timesheet_holidays_task_enable/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/project_timesheet_holidays_task_enable/__manifest__.py b/project_timesheet_holidays_task_enable/__manifest__.py new file mode 100644 index 000000000..6b1e0e53d --- /dev/null +++ b/project_timesheet_holidays_task_enable/__manifest__.py @@ -0,0 +1,15 @@ +# © 2025 Solvos Consultoría Informática () +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html + +{ + "name": "Project Timesheet Holidays - re-enable task", + "summary": "Re-enables task used in leave types", + "category": "Human Resources", + "version": "18.0.1.0.0", + "depends": ["project_timesheet_holidays"], + "data": ["views/project_task_views.xml"], + "author": "Solvos Consultoría Informática, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/timesheet", + "license": "AGPL-3", + "installable": True, +} diff --git a/project_timesheet_holidays_task_enable/i18n/es.po b/project_timesheet_holidays_task_enable/i18n/es.po new file mode 100644 index 000000000..7b9d38e1c --- /dev/null +++ b/project_timesheet_holidays_task_enable/i18n/es.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_timesheet_holidays_task_enable +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-10-08 13:42+0000\n" +"PO-Revision-Date: 2025-10-08 15:44+0200\n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.4.2\n" + +#. module: project_timesheet_holidays_task_enable +#: model:ir.model.fields,help:project_timesheet_holidays_task_enable.field_project_task__timeoff_enable_use_timesheets +msgid "" +"\n" +" For a time off task, re-enables it usage in timesheets\n" +" " +msgstr "" +"\n" +" Para una tarea de ausencias, se rehabilita su uso en partes de horas\n" +" " + +#. module: project_timesheet_holidays_task_enable +#: model:ir.model.fields,field_description:project_timesheet_holidays_task_enable.field_project_task__timeoff_enable_use_timesheets +msgid "Enable use in timesheets when Used in Time Off" +msgstr "Permitir su uso en partes de horas aun cuando es usada en Ausencias" + +#. module: project_timesheet_holidays_task_enable +#: model_terms:ir.ui.view,arch_db:project_timesheet_holidays_task_enable.view_task_form2_inherited +msgid "Enable use in timesheets when used in Time Off" +msgstr "Permitir su uso en partes de horas aun cuando es usada en Ausencias" + +#. module: project_timesheet_holidays_task_enable +#: model:ir.model,name:project_timesheet_holidays_task_enable.model_project_task +msgid "Task" +msgstr "Tarea" diff --git a/project_timesheet_holidays_task_enable/i18n/project_timesheet_holidays_task_enable.pot b/project_timesheet_holidays_task_enable/i18n/project_timesheet_holidays_task_enable.pot new file mode 100644 index 000000000..d3b51c0d7 --- /dev/null +++ b/project_timesheet_holidays_task_enable/i18n/project_timesheet_holidays_task_enable.pot @@ -0,0 +1,39 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_timesheet_holidays_task_enable +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-10-08 13:42+0000\n" +"PO-Revision-Date: 2025-10-08 13:42+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: project_timesheet_holidays_task_enable +#: model:ir.model.fields,help:project_timesheet_holidays_task_enable.field_project_task__timeoff_enable_use_timesheets +msgid "" +"\n" +" For a time off task, re-enables it usage in timesheets\n" +" " +msgstr "" + +#. module: project_timesheet_holidays_task_enable +#: model:ir.model.fields,field_description:project_timesheet_holidays_task_enable.field_project_task__timeoff_enable_use_timesheets +msgid "Enable use in timesheets when Used in Time Off" +msgstr "" + +#. module: project_timesheet_holidays_task_enable +#: model_terms:ir.ui.view,arch_db:project_timesheet_holidays_task_enable.view_task_form2_inherited +msgid "Enable use in timesheets when used in Time Off" +msgstr "" + +#. module: project_timesheet_holidays_task_enable +#: model:ir.model,name:project_timesheet_holidays_task_enable.model_project_task +msgid "Task" +msgstr "" diff --git a/project_timesheet_holidays_task_enable/models/__init__.py b/project_timesheet_holidays_task_enable/models/__init__.py new file mode 100644 index 000000000..edf2d36b9 --- /dev/null +++ b/project_timesheet_holidays_task_enable/models/__init__.py @@ -0,0 +1 @@ +from . import project_task diff --git a/project_timesheet_holidays_task_enable/models/project_task.py b/project_timesheet_holidays_task_enable/models/project_task.py new file mode 100644 index 000000000..61475f2bc --- /dev/null +++ b/project_timesheet_holidays_task_enable/models/project_task.py @@ -0,0 +1,35 @@ +# © 2025 Solvos Consultoría Informática () +# License LGPL-3 - See https://www.gnu.org/licenses/lgpl-3.0.html + +from odoo import fields, models + + +class ProjectTask(models.Model): + _inherit = "project.task" + + timeoff_enable_use_timesheets = fields.Boolean( + string="Enable use in timesheets when Used in Time Off", + help=""" + For a time off task, re-enables it usage in timesheets + """, + ) + + def _compute_is_timeoff_task(self): + res = super()._compute_is_timeoff_task() + self.filtered( + lambda x: x.is_timeoff_task and x.timeoff_enable_use_timesheets + ).is_timeoff_task = False + return res + + def _search_is_timeoff_task(self, operator, value): + domain = super()._search_is_timeoff_task(operator, value) + domain_list = list(domain[0]) + + tasks_ids = domain_list[2] + new_tasks = self.browse(tasks_ids).filtered( + lambda x: x.timeoff_enable_use_timesheets + if value + else not x.timeoff_enable_use_timesheets + ) + domain_list[2] = new_tasks.ids + return [tuple(domain_list)] diff --git a/project_timesheet_holidays_task_enable/pyproject.toml b/project_timesheet_holidays_task_enable/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/project_timesheet_holidays_task_enable/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_timesheet_holidays_task_enable/readme/CONFIGURATION.md b/project_timesheet_holidays_task_enable/readme/CONFIGURATION.md new file mode 100644 index 000000000..c3d4a6818 --- /dev/null +++ b/project_timesheet_holidays_task_enable/readme/CONFIGURATION.md @@ -0,0 +1,3 @@ +1. Go to Project > Task, select task that will be used as Leave Type. On Timesheet page and check "Enable use in timesheets when Used in Time Off" +2. On Time Off>Configuration>Leave Types, with Debug Mode, select Project and Task. +3. Now, from Timesheet, you can create with the enabled task. diff --git a/project_timesheet_holidays_task_enable/readme/CONTRIBUTORS.md b/project_timesheet_holidays_task_enable/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..81e36a5aa --- /dev/null +++ b/project_timesheet_holidays_task_enable/readme/CONTRIBUTORS.md @@ -0,0 +1 @@ +* David ALonso \ diff --git a/project_timesheet_holidays_task_enable/readme/DESCRIPTION.md b/project_timesheet_holidays_task_enable/readme/DESCRIPTION.md new file mode 100644 index 000000000..62c9ad222 --- /dev/null +++ b/project_timesheet_holidays_task_enable/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +When a task is used in leave types configuration, it cannot be used filling manual timesheets. +With this addon, it's possible to re-enable a task affected by this limitation. diff --git a/project_timesheet_holidays_task_enable/static/description/index.html b/project_timesheet_holidays_task_enable/static/description/index.html new file mode 100644 index 000000000..b7844a301 --- /dev/null +++ b/project_timesheet_holidays_task_enable/static/description/index.html @@ -0,0 +1,425 @@ + + + + + +Project Timesheet Holidays - re-enable task + + + +
+

Project Timesheet Holidays - re-enable task

+ + +

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

+

When a task is used in leave types configuration, it cannot be used +filling manual timesheets. With this addon, it’s possible to re-enable a +task affected by this limitation.

+

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

+
    +
  • Solvos Consultoría Informática
  • +
+
+
+

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

+

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

+
+
+
+ + diff --git a/project_timesheet_holidays_task_enable/tests/__init__.py b/project_timesheet_holidays_task_enable/tests/__init__.py new file mode 100644 index 000000000..a8cf14d92 --- /dev/null +++ b/project_timesheet_holidays_task_enable/tests/__init__.py @@ -0,0 +1 @@ +from . import test_project_timesheet_task_enable diff --git a/project_timesheet_holidays_task_enable/tests/test_project_timesheet_task_enable.py b/project_timesheet_holidays_task_enable/tests/test_project_timesheet_task_enable.py new file mode 100644 index 000000000..a337ca2ff --- /dev/null +++ b/project_timesheet_holidays_task_enable/tests/test_project_timesheet_task_enable.py @@ -0,0 +1,67 @@ +# © 202& Solvos Consultoría Informática () +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html + +from odoo.tests.common import TransactionCase, tagged + + +@tagged("post_install", "-at_install") +class TestProjectTaskTimeoff(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.project = cls.env["project.project"].create( + { + "name": "Test Internal Project", + } + ) + + cls.task = cls.env["project.task"].create( + { + "name": "Test Time Off Task 1", + "project_id": cls.project.id, + } + ) + + cls.task_disabled = cls.env["project.task"].create( + { + "name": "Task Disabled", + "project_id": cls.project.id, + "timeoff_enable_use_timesheets": False, + } + ) + + cls.env.company.leave_timesheet_task_id = cls.task.id + cls.leave_type = cls.env["hr.leave.type"].create( + { + "name": "Test Leaves", + "requires_allocation": "no", + "timesheet_project_id": cls.project.id, + "timesheet_task_id": cls.task_disabled.id, + } + ) + + def test_timeoff_enable_use_timesheets_behavior(self): + self.task.is_timeoff_task = True + self.assertTrue(self.task.is_timeoff_task) + + self.task.timeoff_enable_use_timesheets = True + + self.task.invalidate_recordset(["is_timeoff_task"]) + self.assertFalse(self.task.is_timeoff_task) + + def test_search_is_timeoff_task_filtering(self): + self.task.timeoff_enable_use_timesheets = True + + self.leave_type.flush_recordset(["timesheet_project_id", "timesheet_task_id"]) + self.env.invalidate_all() + + result_true = self.task._search_is_timeoff_task("=", True) + ids_true = result_true[0][2] + self.assertIn(self.task.id, ids_true) + self.assertNotIn(self.task_disabled.id, ids_true) + + result_false = self.task._search_is_timeoff_task("=", False) + ids_false = result_false[0][2] + self.assertNotIn(self.task.id, ids_false) + self.assertIn(self.task_disabled.id, ids_false) diff --git a/project_timesheet_holidays_task_enable/views/project_task_views.xml b/project_timesheet_holidays_task_enable/views/project_task_views.xml new file mode 100644 index 000000000..fb008a56e --- /dev/null +++ b/project_timesheet_holidays_task_enable/views/project_task_views.xml @@ -0,0 +1,21 @@ + + + project.task.form.inherited (in project_timesheet_holidays_task_enable) + project.task + + + + + + + + + +