hr_holidays bad checking on workflow actions

Bug #430098 reported by Niels Huylebroeck
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Undecided
Unassigned

Bug Description

hr_holidays/hr.py

The holidays_refuse() (and other functions) do not properly return errors when for example there is no employee linked on the current user.

line 209:
ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])

Needs to check if the ids2 actually contains anything
Needs to raise osv_except when it's empty.

Related branches

affects: openobject-client → openobject-addons
Revision history for this message
Niels Huylebroeck (red15) wrote :

To clarify, you get a list index out of range error when there is no employee linked to the uid.
So it should throw a proper exception explain your login does not have an employee linked or something.

Changed in openobject-addons:
status: New → Confirmed
Revision history for this message
Jay Vora (Serpent Consulting Services) (jayvora) wrote :

Thank you for reporting.
Fixed by revision 2406 <email address hidden>.

Changed in openobject-addons:
status: Confirmed → Fix Released
Revision history for this message
amined_soul (amine) wrote :

    def holidays_validate(self, cr, uid, ids, *args):
        self.check_holidays(cr,uid,ids)
        vals = {
            'state':'validate',
        }
        ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])

        if ids2:
            vals['manager_id'] = ids2[0]
        else:
            raise osv.except_osv(_('Warning !'),_('Either there is no Employee defined, or no User attached with it.'))
        self.write(cr, uid, ids, vals)
        self._create_holiday(cr, uid, ids)
        return True

This code is from the official release, openerp server 5.0.9. the bug is still on it. how to fix it?

Revision history for this message
amined_soul (amine) wrote :

To reproduce that bug:
Create a new database, install hr, then remove the "fabien pinckaers" employee. install hr_holidays. you cannot then validate or refuse any holiday request.

When i'm admin, my uid is then 1.
"ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])"
that code is looking for an employee with id = 1. the employee with id==1 is "fabien pinckaers". if removed, then the error message raises.

Thanks.

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

Hello Amine,

I have tried the same steps and checked at my end.
With no employees on a holidays request,when I validate/refuse the request, it raises the warning that "Either there is no Employee defined, or no User attached with it."

Kindly check again.
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.