Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions project_timesheet_holidays_editable/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===================================================================
Project Timesheet Holidays - re-enable generated timesheets edition
===================================================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:729ca2ced074913d51d934ec8a6604ddca29291c6dbf52c758185403365c1650
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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/19.0/project_timesheet_holidays_editable
:alt: OCA/timesheet
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/timesheet-19-0/timesheet-19-0-project_timesheet_holidays_editable
: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=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

By default, every timesheet generated from a leave becomes read-only, so
nobody can directly edit it and e.g. change its hour count. This
shouldn't occur in Odoo previous versions.

This could be annoying, because for certain leaves (like medical
leaves), final spent time should be different than initial leave filled.
This forces to reject, modify and then approve again leave. Exact time
could not be filled sometimes anyway, due to leave form hour selection.

This addon re-enables timesheet edition when they're generated from
leaves (initially name and quant fields), letting us make it editable
depending on leave type.

**Table of contents**

.. contents::
:local:

Usage
=====

Once installed, it adds a configuration option to define the editability
level of timesheets generated from time off requests at the company
level.

Configuration

After installing the module, follow these steps:

1. Go to Settings (or navigate to Configuration → Settings within the
Timesheets or Time Off apps).
2. Locate the Time Off section (where timesheet generation for leaves is
configured).
3. Make sure an Internal Project (``internal_project_id``) is set. (The
editability configuration menu is only visible if a global internal
project is defined for the company).
4. Configure the Timesheet Edit Level.

Timesheet Restriction Levels

You can define how restrictive the generated timesheets are for the
company:

1. None

- The generated timesheet entries cannot be edited by anyone

2. Officer

- Timesheet entries can only be edited by users belonging to the
group: hr_holidays.group_hr_holidays_user
- Prevents regular employees from modifying generated timesheets

3. All

- Timesheet entries can be edited by any user with access to
timesheets

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/timesheet/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 <https://github.com/OCA/timesheet/issues/new?body=module:%20project_timesheet_holidays_editable%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Solvos Consultoría Informática

Contributors
------------

- `Solvos <https://www.solvos.es>`__:

- David ALonso <david.alonso@solvos.es>
- Carlos García <carlos.garcia@solvos.es>

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 <https://github.com/OCA/timesheet/tree/19.0/project_timesheet_holidays_editable>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions project_timesheet_holidays_editable/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions project_timesheet_holidays_editable/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# © 2026 Solvos Consultoría Informática (<https://www.solvos.es>)
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html

{
"name": "Project Timesheet Holidays - re-enable generated timesheets edition",
"summary": "Re-enables timesheet edition when they're generated from leaves",
"category": "Human Resources",
"version": "19.0.1.0.0",
"depends": ["project_timesheet_holidays"],
"data": ["views/res_config_settings_views.xml"],
"author": "Solvos Consultoría Informática, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/timesheet",
"license": "AGPL-3",
"installable": True,
}
53 changes: 53 additions & 0 deletions project_timesheet_holidays_editable/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_timesheet_holidays_editable
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: it\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"

#. module: project_timesheet_holidays_editable
#: model:ir.model.fields,help:project_timesheet_holidays_editable.field_hr_leave_type__timesheet_edit_level
msgid ""
"\n"
" For this leave type, indicates who can edit generated timesheets\n"
" "
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model.fields.selection,name:project_timesheet_holidays_editable.selection__hr_leave_type__timesheet_edit_level__all
msgid "All"
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model,name:project_timesheet_holidays_editable.model_account_analytic_line
msgid "Analytic Line"
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model.fields.selection,name:project_timesheet_holidays_editable.selection__hr_leave_type__timesheet_edit_level__none
msgid "None"
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model.fields.selection,name:project_timesheet_holidays_editable.selection__hr_leave_type__timesheet_edit_level__approver
msgid "Officer"
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model,name:project_timesheet_holidays_editable.model_hr_leave_type
msgid "Time Off Type"
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model.fields,field_description:project_timesheet_holidays_editable.field_hr_leave_type__timesheet_edit_level
msgid "Timesheet Edit Level"
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_timesheet_holidays_editable
#
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_editable
#: model:ir.model.fields,help:project_timesheet_holidays_editable.field_hr_leave_type__timesheet_edit_level
msgid ""
"\n"
" For this leave type, indicates who can edit generated timesheets\n"
" "
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model.fields.selection,name:project_timesheet_holidays_editable.selection__hr_leave_type__timesheet_edit_level__all
msgid "All"
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model,name:project_timesheet_holidays_editable.model_account_analytic_line
msgid "Analytic Line"
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model.fields.selection,name:project_timesheet_holidays_editable.selection__hr_leave_type__timesheet_edit_level__none
msgid "None"
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model.fields.selection,name:project_timesheet_holidays_editable.selection__hr_leave_type__timesheet_edit_level__approver
msgid "Officer"
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model,name:project_timesheet_holidays_editable.model_hr_leave_type
msgid "Time Off Type"
msgstr ""

#. module: project_timesheet_holidays_editable
#: model:ir.model.fields,field_description:project_timesheet_holidays_editable.field_hr_leave_type__timesheet_edit_level
msgid "Timesheet Edit Level"
msgstr ""
3 changes: 3 additions & 0 deletions project_timesheet_holidays_editable/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import res_company
from . import res_config_settings
from . import account_analytic_line
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# © 2026 Solvos Consultoría Informática (<https://www.solvos.es>)
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html

from odoo import api, models


class AccountAnalyticLine(models.Model):
_inherit = "account.analytic.line"

def _check_can_write(self, values):
# A holiday generated timesheet can only be modified if holiday type
# allows it for everybody, or if the user is an approver
obj = self
holiday = self.sudo().holiday_id
if (
holiday
and (
holiday.employee_id.company_id.timesheet_edit_level == "all"
or (
holiday.employee_id.company_id.timesheet_edit_level == "approver"
and self.env.user.has_group("hr_holidays.group_hr_holidays_user")
)
)
and (not set(values.keys()) - set(self._get_ts_from_holiday_edit_fields()))
):
obj = self.sudo()
return super(AccountAnalyticLine, obj)._check_can_write(values)

@api.model
def _get_ts_from_holiday_edit_fields(self):
return ["name", "unit_amount"]
14 changes: 14 additions & 0 deletions project_timesheet_holidays_editable/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# © 2026 Solvos Consultoría Informática (<https://www.solvos.es>)
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html

from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

timesheet_edit_level = fields.Selection(
selection=[("none", "None"), ("approver", "Officer"), ("all", "All")],
default="none",
string="Timesheet Edit Level for Time Off",
)
17 changes: 17 additions & 0 deletions project_timesheet_holidays_editable/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# © 2026 Solvos Consultoría Informática (<https://www.solvos.es>)
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

timesheet_edit_level = fields.Selection(
related="company_id.timesheet_edit_level",
readonly=False,
string="Timesheet Edit Level for Time Off",
help="""
Indicates who can edit generated timesheets
""",
)
3 changes: 3 additions & 0 deletions project_timesheet_holidays_editable/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
3 changes: 3 additions & 0 deletions project_timesheet_holidays_editable/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [Solvos](https://www.solvos.es):
- David ALonso \<david.alonso@solvos.es\>
- Carlos García \<carlos.garcia@solvos.es\>
5 changes: 5 additions & 0 deletions project_timesheet_holidays_editable/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
By default, every timesheet generated from a leave becomes read-only, so nobody can directly edit it and e.g. change its hour count. This shouldn't occur in Odoo previous versions.

This could be annoying, because for certain leaves (like medical leaves), final spent time should be different than initial leave filled. This forces to reject, modify and then approve again leave. Exact time could not be filled sometimes anyway, due to leave form hour selection.

This addon re-enables timesheet edition when they're generated from leaves (initially name and quant fields), letting us make it editable depending on leave type.
24 changes: 24 additions & 0 deletions project_timesheet_holidays_editable/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Once installed, it adds a configuration option to define the editability level of timesheets generated from time off requests at the company level.

Configuration

After installing the module, follow these steps:

1. Go to Settings (or navigate to Configuration → Settings within the Timesheets or Time Off apps).
2. Locate the Time Off section (where timesheet generation for leaves is configured).
3. Make sure an Internal Project (`internal_project_id`) is set. (The editability configuration menu is only visible if a global internal project is defined for the company).
4. Configure the Timesheet Edit Level.

Timesheet Restriction Levels

You can define how restrictive the generated timesheets are for the company:

1. None
- The generated timesheet entries cannot be edited by anyone

2. Officer
- Timesheet entries can only be edited by users belonging to the group: hr_holidays.group_hr_holidays_user
- Prevents regular employees from modifying generated timesheets

3. All
- Timesheet entries can be edited by any user with access to timesheets
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading