diff --git a/project_timesheet_holidays_dynamic_description/README.rst b/project_timesheet_holidays_dynamic_description/README.rst new file mode 100644 index 0000000000..e1dd8a62e4 --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/README.rst @@ -0,0 +1,86 @@ +============================================== +Project Timesheet Holidays Dynamic Description +============================================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:2bec8baa54dc1cec4f4289d5c4cbbff5227251844e44761df2145551f4ef2176 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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/17.0/project_timesheet_holidays_dynamic_description + :alt: OCA/timesheet +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/timesheet-17-0/timesheet-17-0-project_timesheet_holidays_dynamic_description + :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=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +Use the time off description for the generated timesheet lines. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +Activate "Dynamic Descriptions" in the Leave Type settings. From that +point on, whenever a timesheet line is generated using that Leave Type, +the description set in the leave will be assigned to the Timesheet Line +. + +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 +------------ + +- `Solvos `__: + + - Carlos García + +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_dynamic_description/__init__.py b/project_timesheet_holidays_dynamic_description/__init__.py new file mode 100644 index 0000000000..0650744f6b --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/project_timesheet_holidays_dynamic_description/__manifest__.py b/project_timesheet_holidays_dynamic_description/__manifest__.py new file mode 100644 index 0000000000..df39a0903f --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/__manifest__.py @@ -0,0 +1,17 @@ +# © 2026 Solvos Consultoría Informática () +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html + +{ + "name": "Project Timesheet Holidays Dynamic Description", + "summary": """ + Use the time off description for the generated timesheet lines. + """, + "category": "Human Resources", + "version": "17.0.1.0.0", + "depends": ["project_timesheet_holidays"], + "data": ["views/hr_holidays_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_dynamic_description/i18n/es.po b/project_timesheet_holidays_dynamic_description/i18n/es.po new file mode 100644 index 0000000000..959a4aa7d7 --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/i18n/es.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_timesheet_holidays_dynamic_description +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-04-16 17:45+0000\n" +"Last-Translator: \"David Alonso (Solvos)\" \n" +"Language-Team: none\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.15.2\n" + +#. module: project_timesheet_holidays_dynamic_description +#: model:ir.model.fields,field_description:project_timesheet_holidays_dynamic_description.field_hr_leave_type__dynamic_timesheet_description +msgid "Dynamic Description" +msgstr "Descripción dinámica" + +#. module: project_timesheet_holidays_dynamic_description +#: model:ir.model.fields,help:project_timesheet_holidays_dynamic_description.field_hr_leave_type__dynamic_timesheet_description +msgid "" +"If enabled, timesheets generated from time off will contains the leave " +"description." +msgstr "" +"Si está habilitado, los partes de horas generados desde la ausencia " +"contendrán la descripción de la ausencia." + +#. module: project_timesheet_holidays_dynamic_description +#: model:ir.model,name:project_timesheet_holidays_dynamic_description.model_hr_leave +msgid "Time Off" +msgstr "Ausencia" + +#. module: project_timesheet_holidays_dynamic_description +#: model:ir.model,name:project_timesheet_holidays_dynamic_description.model_hr_leave_type +msgid "Time Off Type" +msgstr "Tipo de ausencia" diff --git a/project_timesheet_holidays_dynamic_description/i18n/project_timesheet_holidays_dynamic_description.pot b/project_timesheet_holidays_dynamic_description/i18n/project_timesheet_holidays_dynamic_description.pot new file mode 100644 index 0000000000..4e7baf3721 --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/i18n/project_timesheet_holidays_dynamic_description.pot @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * project_timesheet_holidays_dynamic_description +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \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_dynamic_description +#: model:ir.model.fields,field_description:project_timesheet_holidays_dynamic_description.field_hr_leave_type__dynamic_timesheet_description +msgid "Dynamic Description" +msgstr "" + +#. module: project_timesheet_holidays_dynamic_description +#: model:ir.model.fields,help:project_timesheet_holidays_dynamic_description.field_hr_leave_type__dynamic_timesheet_description +msgid "" +"If enabled, timesheets generated from time off will contains the leave " +"description." +msgstr "" + +#. module: project_timesheet_holidays_dynamic_description +#: model:ir.model,name:project_timesheet_holidays_dynamic_description.model_hr_leave +msgid "Time Off" +msgstr "" + +#. module: project_timesheet_holidays_dynamic_description +#: model:ir.model,name:project_timesheet_holidays_dynamic_description.model_hr_leave_type +msgid "Time Off Type" +msgstr "" diff --git a/project_timesheet_holidays_dynamic_description/models/__init__.py b/project_timesheet_holidays_dynamic_description/models/__init__.py new file mode 100644 index 0000000000..775298acfd --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/models/__init__.py @@ -0,0 +1,2 @@ +from . import hr_leave +from . import hr_leave_type diff --git a/project_timesheet_holidays_dynamic_description/models/hr_leave.py b/project_timesheet_holidays_dynamic_description/models/hr_leave.py new file mode 100644 index 0000000000..49c94822c1 --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/models/hr_leave.py @@ -0,0 +1,21 @@ +# © 2026 Solvos Consultoría Informática () +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html + +from odoo import models + + +class HrLeave(models.Model): + _inherit = "hr.leave" + + def _timesheet_prepare_line_values( + self, index, work_hours_data, day_date, work_hours_count, project, task + ): + timesheet_line = super()._timesheet_prepare_line_values( + index, work_hours_data, day_date, work_hours_count, project, task + ) + + if self.holiday_status_id.dynamic_timesheet_description and self.name: + old_ts_line = timesheet_line.get("name", "") + timesheet_line["name"] = self.name + " - " + old_ts_line + + return timesheet_line diff --git a/project_timesheet_holidays_dynamic_description/models/hr_leave_type.py b/project_timesheet_holidays_dynamic_description/models/hr_leave_type.py new file mode 100644 index 0000000000..084799de13 --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/models/hr_leave_type.py @@ -0,0 +1,15 @@ +# © 2026 Solvos Consultoría Informática () +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html + +from odoo import fields, models + + +class HolidaysType(models.Model): + _inherit = "hr.leave.type" + + dynamic_timesheet_description = fields.Boolean( + string="Dynamic Description", + default=True, + help="If enabled, timesheets generated from time off " + "will contains the leave description.", + ) diff --git a/project_timesheet_holidays_dynamic_description/pyproject.toml b/project_timesheet_holidays_dynamic_description/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_timesheet_holidays_dynamic_description/readme/CONTRIBUTORS.md b/project_timesheet_holidays_dynamic_description/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..a6fdccacf1 --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Solvos](https://www.solvos.es): + - Carlos García \ diff --git a/project_timesheet_holidays_dynamic_description/readme/DESCRIPTION.md b/project_timesheet_holidays_dynamic_description/readme/DESCRIPTION.md new file mode 100644 index 0000000000..eecb458a7e --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/readme/DESCRIPTION.md @@ -0,0 +1 @@ +Use the time off description for the generated timesheet lines. diff --git a/project_timesheet_holidays_dynamic_description/readme/USAGE.md b/project_timesheet_holidays_dynamic_description/readme/USAGE.md new file mode 100644 index 0000000000..4c4356f6c2 --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/readme/USAGE.md @@ -0,0 +1 @@ +Activate "Dynamic Descriptions" in the Leave Type settings. From that point on, whenever a timesheet line is generated using that Leave Type, the description set in the leave will be assigned to the Timesheet Line . diff --git a/project_timesheet_holidays_dynamic_description/static/description/icon.png b/project_timesheet_holidays_dynamic_description/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_timesheet_holidays_dynamic_description/static/description/icon.png differ diff --git a/project_timesheet_holidays_dynamic_description/static/description/index.html b/project_timesheet_holidays_dynamic_description/static/description/index.html new file mode 100644 index 0000000000..45c0b9d28f --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/static/description/index.html @@ -0,0 +1,434 @@ + + + + + +Project Timesheet Holidays Dynamic Description + + + +
+

Project Timesheet Holidays Dynamic Description

+ + +

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

+

Use the time off description for the generated timesheet lines.

+

Table of contents

+ +
+

Usage

+

Activate “Dynamic Descriptions” in the Leave Type settings. From that +point on, whenever a timesheet line is generated using that Leave Type, +the description set in the leave will be assigned to the Timesheet Line +.

+
+
+

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_dynamic_description/tests/__init__.py b/project_timesheet_holidays_dynamic_description/tests/__init__.py new file mode 100644 index 0000000000..b3bdbd7c86 --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/tests/__init__.py @@ -0,0 +1 @@ +from . import test_project_timesheet_holidays_description diff --git a/project_timesheet_holidays_dynamic_description/tests/test_project_timesheet_holidays_description.py b/project_timesheet_holidays_dynamic_description/tests/test_project_timesheet_holidays_description.py new file mode 100644 index 0000000000..4d68cc70ec --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/tests/test_project_timesheet_holidays_description.py @@ -0,0 +1,118 @@ +# © 2026 Solvos Consultoría Informática () +# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html + +from odoo import Command, fields +from odoo.tests.common import TransactionCase, tagged + + +@tagged("post_install", "-at_install") +class TestProjectTimesheetHolidaysDescription(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + + cls.Employee = cls.env["hr.employee"] + cls.LeaveType = cls.env["hr.leave.type"] + cls.Leave = cls.env["hr.leave"] + cls.AnalyticLine = cls.env["account.analytic.line"] + + cls.Project = cls.env["project.project"] + cls.Task = cls.env["project.task"] + + cls.user_employee = cls.env["res.users"].create( + { + "name": "HR Employee", + "login": "hr_employee", + "groups_id": [ + Command.set( + [ + cls.env.ref("hr_timesheet.group_hr_timesheet_user").id, + ] + ) + ], + } + ) + + cls.user_approver = cls.env["res.users"].create( + { + "name": "HR Approver", + "login": "hr_approver", + "groups_id": [ + Command.set( + [ + cls.env.ref("hr_holidays.group_hr_holidays_user").id, + cls.env.ref("project.group_project_manager").id, + ] + ) + ], + } + ) + + cls.project = cls.Project.create( + { + "name": "Project Vacations", + } + ) + + cls.task = cls.Task.create( + { + "name": "Vacations Task", + "project_id": cls.project.id, + } + ) + + cls.employee = cls.Employee.create( + { + "name": "Test Employee", + "user_id": cls.user_employee.id, + } + ) + + cls.leave_type = cls.LeaveType.create( + { + "name": "Leave Test", + "requires_allocation": "no", + "timesheet_generate": True, + "timesheet_project_id": cls.project.id, + "timesheet_task_id": cls.task.id, + "dynamic_timesheet_description": True, + } + ) + + def _create_leave_with_timesheet(self): + self.leave = self.Leave.create( + { + "name": "Vacations", + "employee_id": self.employee.id, + "holiday_status_id": self.leave_type.id, + "request_date_from": fields.Date.today(), + "request_date_to": fields.Date.today(), + } + ) + + self.leave.action_validate() + + ts = self.AnalyticLine.search([("holiday_id", "=", self.leave.id)], limit=1) + + self.assertTrue(ts) + return ts + + def test_match_timesheet_and_leave_description(self): + ts = self._create_leave_with_timesheet() + + self.assertTrue( + ts.name.startswith(self.leave.name), + "The timesheet name should start with the leave description", + ) + + def test_no_match_when_config_disabled(self): + self.leave_type.dynamic_timesheet_description = False + + ts = self._create_leave_with_timesheet() + + self.assertNotIn( + self.leave.name, + ts.name, + "The timesheet name should not contain the " + "leave name when the config is disabled.", + ) diff --git a/project_timesheet_holidays_dynamic_description/views/hr_holidays_views.xml b/project_timesheet_holidays_dynamic_description/views/hr_holidays_views.xml new file mode 100644 index 0000000000..e6a300937a --- /dev/null +++ b/project_timesheet_holidays_dynamic_description/views/hr_holidays_views.xml @@ -0,0 +1,20 @@ + + + hr.leave.type.form (in project_timesheet_holidays_leave_description_on_ts_lines) + hr.leave.type + + + + + + + +