[Trunk/7.0] I can't add hours to open task, if the timesheet is confirmed

Bug #1174650 reported by Carlos Pueyo
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Committed
Medium
OpenERP Publisher's Warranty Team

Bug Description

Version OpenERP: https://demo1.openerp.com/ (2013-04-30)

Steps to reproduce:

- Go to Project -> Tasks
- Register any hours in the worklog in a open task, example in 2013-04-13.
- Go to Human Resources -> My timesheet
- Register a timesheet between 2013-04-15 to 2013-04-21.
- Send to approval.
- Approval it.
- Go to Project -> Tasks
- Register any new hours in the working log in the same OPEN task, in 2013-04-30.
- Error, You cannot modify hours in a confirmed timesheet. What?
- Trying to impute hours with other employee in the same task, other day not in period of the timesheet.
- Error, You cannot modify hours in a confirmed timesheet. But i try to register worklog with other user with no timesheet, what's happen?

Related branches

Carlos Pueyo (cpueyo)
description: updated
description: updated
tags: added: project task timesheet
Carlos Pueyo (cpueyo)
description: updated
Changed in openobject-addons:
status: New → Confirmed
Carlos Pueyo (cpueyo)
summary: - I can't add hours to open task, if the timesheet is closed
+ I can't add hours to open task, if the timesheet is confirmed
Carlos Pueyo (cpueyo)
tags: added: 7.0
summary: - I can't add hours to open task, if the timesheet is confirmed
+ [7.0] I can't add hours to open task, if the timesheet is confirmed
Revision history for this message
Amit Parik (amit-parik) wrote :

Good One Carlos...we have to fix this ASAP.

Thank You!

summary: - [7.0] I can't add hours to open task, if the timesheet is confirmed
+ [Trunk/7.0] I can't add hours to open task, if the timesheet is
+ confirmed
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Medium
Revision history for this message
Carlos Pueyo (cpueyo) wrote :

Hello!

I did a patch for it :)

Before create or write the hr_analytic_timesheet, check if the values of the line is changed.

        # We check the state of the sheet
        estado = self._check_sheet_state(cr, uid, ids)
        # if estado is False, the sheet is confirmed or done
        if estado is False:
            # We test if the values are changed
            if vals:
                raise osv.except_osv(_('Error!'),
                    _('You cannot modify an entry in a Confirmed/Done timesheet!'))
            else:
                # If no values are changed, we clean the ids, for not do validation
                ids = []

        return super(hr_analytic_timesheet, self).write(cr, uid, ids, vals, *args, **argv)

Revision history for this message
Carlos Pueyo (cpueyo) wrote :

Sorry, this patch only work with write method.

Revision history for this message
Carlos Pueyo (cpueyo) wrote :

Ok. I do too a patch for create method.

Write Method:

Same of comment #2

Create Method Override:

    def _check_estado_hoja(self, cr, uid, ids, context=None):
        osv.logging.log(100, "[Alca] _check_estado_hoja:hr_analytic_timesheet:hr_timesheet_project")
        if context is None:
            context = {}
        bSheet = self.pool.get("hr_timesheet_sheet.sheet").browse(cr, uid, ids[0], context=context)
        if hasattr(bSheet, 'state') and bSheet.state not in ('draft', 'new'):
            return False
        return True

    def create(self, cr, uid, vals, *args, **argv):
        osv.logging.log(100, "[Alca] create:hr_analytic_timesheet:hr_timesheet_project" + str(vals))
        id_hr = super(hr_analytic_timesheet, self).create(cr, uid, vals, *args, **argv)

        sheet = self._sheet(cr, uid, [id_hr], None, None)

        if sheet:
            sheet_id = sheet.values()[0][0]
        # Comprobamos el estado de la hoja
        estado = self._check_estado_hoja(cr, uid, [sheet_id])
        # Si el estado es False, significa que esta cerrada
        if estado is False:
            # Comprobamos si hay valores modificados
            if vals:
                raise osv.except_osv(_('Error!'),
                    _('You cannot create an entry in a Confirmed/Done timesheet!'))
            else:
                # Si no hay valores modificados, limpiamos los identificadores, para poder saltarnos la comprobacion
                ids = []

        return id_hr

Revision history for this message
Carlos Pueyo (cpueyo) wrote :
Changed in openobject-addons:
assignee: OpenERP R&D Addons Team 3 (openerp-dev-addons3) → OpenERP Publisher's Warranty Team (openerp-opw)
tags: added: maintenance
Revision history for this message
Foram Katharotiya (OpenERP) (fka-openerp) wrote :

Hello,

  - It has been Fixed in this branch https://code.launchpad.net/~openerp-dev/openobject-addons/7.0-opw-597447-fka
    revno: 9416
    revid: <email address hidden>

  -It will be available in 7.0 soon.

Thanks,
FKA

Changed in openobject-addons:
status: Confirmed → Fix Committed
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.