Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hr_timesheet_sheet: Unable to add new line on sheet if project_timesheet_holidays is installed #711

Closed
maisim opened this issue Sep 10, 2024 · 1 comment · Fixed by #712
Labels

Comments

@maisim
Copy link

maisim commented Sep 10, 2024

Module

hr_timesheet_sheet

Describe the bug

When we add a line to a sheet wich contains a time off line, we have an Error:
You cannot modify timesheets that are linked to time off requests. Please use the Time Off application to modify your time off requests instead

Some mechanisms has been introduced to avoid holidays modifications from other places than holidays app:

https://github.com/odoo/odoo/blob/c226098a20e9d70090bc9ae6b4c2b82483ae0f4b/addons/project_timesheet_holidays/models/account_analytic.py#L31-L37

You can see here the changes made to be able to bypass this:
odoo/odoo#120597

By the way, I think the useful solution was the first proposal, but...

A change in hr_timesheet_sheet to get it working is here:

def _check_can_update_timesheet(self):
return super()._check_can_update_timesheet() or not self.filtered("sheet_id")

The problem is, when we add a new line on a sheet, all related account analytic line records are updated, even the ones already have the good sheet_id defined, because of:

self.timesheet_ids |= self.env["account.analytic.line"]._sheet_create(
values
)

The solution is to just add new records:

new_line = self.env['account.analytic.line']._sheet_create(values)
self.write({'timesheet_ids': [(4, new_line.id)]})

## Versions

  • 16.0

A PR is comming

@maisim maisim added the bug label Sep 10, 2024
maisim added a commit to maisim/timesheet that referenced this issue Sep 10, 2024
@maisim
Copy link
Author

maisim commented Sep 10, 2024

Hi @alexey-pelykh @gurneyalex !
can any of you take a look at it please ? 😄

maisim added a commit to maisim/timesheet that referenced this issue Sep 16, 2024
Fixes inability to add lines to timesheets that containstime off lines,
managed from project_timesheet_holidays.

Fixes OCA#711
@pedrobaeza pedrobaeza linked a pull request Sep 16, 2024 that will close this issue
SodexisTeam pushed a commit to sodexis/timesheet that referenced this issue Oct 18, 2024
Fixes inability to add lines to timesheets that containstime off lines,
managed from project_timesheet_holidays.

Fixes OCA#711
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants