[5.0+trunk] hr_holidays : Cannot validate last day of leave

Bug #649703 reported by Niels Huylebroeck
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Status tracked in Trunk
5.0
Invalid
Undecided
Niels Huylebroeck
Trunk
Invalid
Undecided
Niels Huylebroeck

Bug Description

Quite simply put, the comparison does not make sense at all :

hr_holidays/hr.py : 267
         if leaves_rest < leave_asked:
               raise osv.except_osv(_('Attention!'),_('You Cannot Validate leaves while available leaves are less than asked leaves.'))

This equation has to be reversed,
        if leave_asked > leaves_rest:

Changed in openobject-addons:
assignee: nobody → Niels Huylebroeck (niels-bubbles-it)
Revision history for this message
Niels Huylebroeck (red15) wrote :

Noticed this was also happening in v6, branch on the way.

summary: - [5.0] hr_holidays : Cannot validate last day of leave
+ [5.0+trunk] hr_holidays : Cannot validate last day of leave
Revision history for this message
Niels Huylebroeck (red15) wrote :

Seems the calculation of leaves_rest also contains non-validated holidays, thus it will never allow you to validate the last days because they count already as 'taken'.

Revision history for this message
qdp (OpenERP) (qdp) wrote :

Hi,

as far as i know, A < B or B > A have exactly the same effect :-D

I didn't check the validity of your bug, but it seems that the way you're proposing to solve it is not totally correct ^^

Quentin

Revision history for this message
Niels Huylebroeck (red15) wrote :

Yes you're right Quentin, jumped the gun a bit. I have seen now that the cause is something different, read comment #2 please.

Revision history for this message
JMA(Open ERP) (jma-openerp) wrote :

Hello Niels Huylebroeck,

It seems you have misinterpreted few things.

If leaves_rest = max_leaves - leaves_taken

for user A
       if max_leaves = 10,
           leaves taken = 6,
           leaves_rest = 10 - 6 = 4.

In our case we have leaves_rest = 4, If the user now makes a leave request fro 5 days
i.e if leaves_rest < leave_asked:
 the exception would come up.

In respect to your comment #2 :
If you have set the checkbox "Allow To Override Limit " true, then it will by pass all the check & allow you to request holiday then the actual number of days available.

Let us know if I am missing out something.

Thanks.

Revision history for this message
Niels Huylebroeck (red15) wrote :

Yes, but it seems the problem is leaves_taken can easily be fooled, I cannot exactly say how this particular case has happened but try adding / deleting / canceling some holiday requests and soon your leaves_taken stays higher than the actual value.

I have not looked at v6 code enough to know if that is now solved or not but I know the holiday requests are far from 'user-proof'. Try for example duplicating a request (the state is duplicated as well leaving the workflow in an unusable state)

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Hello Niels,

I have seen this issue.

The current code has covered three basic points where these 2 fields 'leaves taken' and 'max leaves allowed' should take an effect.
1. Validation of leave.
2. Cancellation of leave.
3. Deletion of Leave.

Let me know if you find a case when you can get the max. leaves fooled (Except where the status of holidays has 'Allow to override limit' set True).

Thanks.

Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

I am closing the issue as there does not seem any chance to generate it.
If it happens, we will be working for the efficient solution.
Thanks.

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

Other bug subscribers

Remote bug watches

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