[6.0] Incorrect permissions on hr.timesheet_sheet workflow causes multiple issues for normal employees

Bug #794634 reported by Stéphane Bidoul (Acsone)
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
High
Unassigned
6.0
Fix Released
High
OpenERP Publisher's Warranty Team

Bug Description

As described in the comments of the bug, the root issue here is the fact that the NEW->DRAFT workflow transition is restricted to the HR Officer groups, whereas it should be allowed for any Employee. In fact the second transition DRAFT->CONFIRM should also be allowed for any Employee, as it is the proper way to submit your own timesheet to your manager for approval.
The group restriction on these transitions should be adapted accordingly.

====== original description below ======

Hi,

When clicking on My Timesheet menu entry, a new timesheet is created, even if a timesheet already exists for the current week.

How to reproduce:
- openerp 6.0 series with demo data
- login with fbs/fbs
- go to Human Resources / Time Tracking / My Timesheet
- save the new timesheet
- go to Human Resources / Time Tracking / My Timesheet agin
- save the timesheet
- error: Error occurred while validating the field(s) date_from,date_to: You can not have 2 timesheets that overlaps !
Please use the menu 'My Current Timesheet' to avoid this problem.

IMO, this is due to a fact that the query for existing timesheet filters on (state='draft'). This filter on state should be removed.

Proposed patch attached.

Best regards,

-sbi

Tags: maintenance

Related branches

Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

I also noticed that when you save the timesheet opened from "My Timesheet" it stays in the "new" state and therefore the Confirm button does not appear.

-sbi

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello Stephane,

I have checked your issue But I think the current behavior is right and no need to improve it.

Currently we can not allow to override the time-sheet so you can faced the constraint error "error: Error occurred while validating the field(s) date_from,date_to: You can not have 2 timesheets that overlaps !" which is the behavior.

When you open the "My Timesheet" menu it will open the current time sheet and when you create a new time-sheet then you must change the period of the time-sheet. When you create new time-sheet it is in "new" state and when you save the time-sheet it will goes in to "Draft" state ans you will see the "Confirm " button which is proper.

When you open the "My Timesheet" menu it will open the current time sheet so first it will search the "Draft" state's time-sheet which is in current period that's why no need to remove the (state','=','draft').

For your comment#2 when you open the "My timesheet "menu first it search the current period 's timesheet which is in "Draft" state and if it is not found then it will create a new time-sheet which is in "new" state and when you save the timesheet it goes in to the "Draft" state and you can see the "Confirm" button.

So this is the current flow not a bug.

That's why I am closing this bug hope my specification help for you.

Thanks

Changed in openobject-addons:
status: New → Invalid
Changed in openobject-addons:
status: Invalid → New
Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Hi Amit,

The error message about overlapping timesheets is normal indeed.

However, in the procedure I described above, when there is already a timesheet in state 'new' or 'confirmed' (ie any state != 'draft'), the system creates a new timesheet when clicking "My Timesheet" instead of showing the existing timesheet. This is disturbing for the user.

I encoutered the problem because I tested with users in the Employee group. Such users can create timesheets, but such timesheet always stay in 'new' state (because users must be in the 'Human Resource / User' group for the timesheet workflow correctly). This is disturbing too.

Best regards,

-sbi

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello,

This is not a bug and it 's suggestion.

So we need to more discussion on this.

That's why Currently I am set is an "Opinion".

Thanks and more suggestions are welcomed!

Changed in openobject-addons:
status: New → Opinion
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hi,

I described the issue here too (and set it as duplicate) : https://bugs.launchpad.net/openobject-addons/+bug/716376

The problem is not in the wizard which search for the "draft" timesheet.
It is in the workflow which requires the UR User group in the transition from new to draft.

Employees can create timesheets, it is a nonsense if they can create them but they stay in new instead of draft.

I consider this as a bug, because if an employee click on "My Timesheet", save it, and click again on "My Timesheet", his timesheet will not be opened, but a new one, and he won't be able to access to the timesheet he just created.

And if a HR user do the same, his correct timesheet will be opened.

Thanks

Revision history for this message
Stéphane Bidoul (Acsone) (sbi) wrote :

Hi,

Thanks for the clarification. I finally reached the same conclusion that it is a problem with the default workflow permissions.

-sbi

Changed in openobject-addons:
status: Opinion → Confirmed
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Stéphane, Guewen,

You're right, the transition for the "new" state to the "draft" state should be allowed for any member of the "Employee" group.
Restricting it to the HR Officers causes various issues as you noticed, one of them being the creation of multiple timesheets for the same period.

This was fixed recently in trunk with revision 4892 revid:<email address hidden>.

I'm raising the importance to High because this can make the timesheet system quite unusable for users that are unaware of this workflow configuration issue. Having importance High makes it eligible for backporting to 6.0 without an explicit OpenERP Enterprise ticket, therefore I'm assigning it to the related team for the 6.0 branch.

Many thanks to both of you for reporting and taking the time to properly identify the root cause of the issue!

Changed in openobject-addons:
importance: Undecided → High
milestone: none → 6.1
status: Confirmed → Fix Released
summary: - [6.0] Clicking on "my timesheet" always creates a duplicate timesheet
- for period
+ [6.0] Incorrect permissions on hr.timesheet_sheet workflow causes
+ multiple issues for normal employees
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

As this is a High importance issue, I'm assigning this to the OPW team for considering a backport of the fix in 6.0.
The fix was merged in trunk at revision 4892, but see more specifically the revision 4714.19.1 revid:<email address hidden> for the relevant fix to fix hr_timesheet_sheet/hr_timesheet_workflow.xml
Thanks!

description: updated
tags: added: maintenance
Revision history for this message
Riken Bhorania (OpenERP) (rch-openerp) wrote :

Hello Stéphane Bidoul,

Your effort is highly appreciated for pointing out this problem.

Thanks a lot to Guewen Baconnier for explaining desired functionality.

@Olivier Dony: Thanks for providing valuable suggestions.

Its now fixed in,
lp:~openerp-dev/openobject-addons/6.0-opw-17103-rch
Revision no: 4785

Stable v6 will be updated soon with this.

Best regards.

Revision history for this message
Rifakat Husen (OpenERP) (rha-openerp) wrote :

Landed on stable 6.0,
Revision ID: <email address hidden>
Revision 4809

Revision history for this message
sambasivarao (gs9783) wrote :

I am facing this probelm in version 7.0. Please can any one say weather it is solved or not in version 7.0?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.