timesheet icon indicating copy to clipboard operation
timesheet copied to clipboard

[16.0][FIX]hr_timesheet_sheet: handle new analityc line when previous sheet was confirmed

Open PicchiSeba opened this issue 9 months ago • 2 comments

When creating a new line on a project task via the "Start Work", if there is another line which is present in a hr_timesheet_sheet in state confirm or done, the new line will be created by duplicating the last one.

Which means creating a new line with the same sheet_id. The new line is then updated with a new sheet (the corresponding one if there is one, None otherwise). This sheet change triggers the _check_state method before assigning the new sheet, which raises the error.

Steps to reproduce on runboat:

  1. log as admin into baseonly db
  2. install hr_timesheet_sheet and project_timesheet_time_control modules
  3. create a new timesheet for the current week (also stop tasks that are currently active)
  4. select a task and change one of the lines' day to the last working day of this week
  5. confirm timesheet
  6. go on the same task where you changed day, click on "Start Work" to create a new line. Let it start in the following week
  7. observe error "You cannot modify an entry in a confirmed timesheet sheet"

Expected behavior: you should be able to create a line on the following week, like in version 14.0

PicchiSeba avatar Mar 18 '25 12:03 PicchiSeba

I'm not entirely sure how it worked on v14, but I think a more elegant solution would be set copy=False on field sheet_id of account.analytic.line so that the duplicated line is not immediately linked to the old sheet..

What do you think? Would that work?

aleuffre avatar Mar 20 '25 12:03 aleuffre

I'm not entirely sure how it worked on v14, but I think a more elegant solution would be set copy=False on field sheet_id of account.analytic.line so that the duplicated line is not immediately linked to the old sheet..

What do you think? Would that work?

Yes, that would also work. But I'm not sure if some other module in this repo in relying on the copy of sheet_id. I will go on with your solution as it is indeed more elegant.

PicchiSeba avatar Mar 21 '25 09:03 PicchiSeba

@OCA/human-resources-maintainers can this small fix be merged please :pray:

aleuffre avatar May 23 '25 10:05 aleuffre

/ocabot merge minor

Saran440 avatar May 26 '25 06:05 Saran440

What a great day to merge this nice PR. Let's do it! Prepared branch 16.0-ocabot-merge-pr-754-by-Saran440-bump-minor, awaiting test results.

OCA-git-bot avatar May 26 '25 06:05 OCA-git-bot

Congratulations, your PR was merged at 681cd85f29a82453bf7b0cfa1d321fca57d7d909. Thanks a lot for contributing to OCA. ❤️

OCA-git-bot avatar May 26 '25 06:05 OCA-git-bot