can't add new work to task if there's already work for a confirm/done timesheet

Bug #1023047 reported by Javier Castillo
68
This bug affects 14 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Committed
Medium
OpenERP R&D Addons Team 1
OpenERP Community Backports (Addons)
Status tracked in 7.0
7.0
Fix Released
Undecided
Holger Brunn (Therp)
Therp Backports (Deprecated)
Status tracked in Addons-6.1
Addons-6.1
Fix Released
Undecided
Unassigned

Bug Description

OpenERP version is 6.1.1, with modules hr_timesheet_sheet and project_timesheet.

Steps to reproduce:
1) Create a timesheet for an employee
2) Create a task and log some work, timesheet lines will be created (to have this working I had to apply the patch described in https://bugs.launchpad.net/openobject-addons/+bug/949078 )
3) Submit the timesheet for approval
4) Try to log more work on the task

Observed result: I'm getting an error message that says that a timesheet line cannot be updated if the timesheet is confirm/done.

Expected result: User should be able to add more work and new timesheet lines should be created, not updating the old ones that already belong to a confirm/done timesheet.

Possible fix:
To fix this issue I added this code in file project_timesheet.py, inside write function for class project_work:

            if line_id.sheet_id.state in ['confirm','done']:
                # ignore changes if timesheet is in confirm or done status
                continue

I added the lines inside the "for task" just after the line_id null verification. With this is now working for me.

Related branches

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

Hello Javier,

I do not agree with that we have to allow new timesheet line entry for the same period of old timesheet.
If we have to allow more then one timesheet for same period,then we can not manage then properly as well as allow to create new timesheet line (as you said) which will create a new timesheet. So for then same period more then one time doesn't exist (for one user).

So You if you want to manage this thing, First you have to set your timesheet(already created) on draft state. Edit your timesheet or enter the task work entry. Then again confirmed you timesheet . This is simple flow and doesn't create any misleading.

That's we can not consider this point as a "vaild", So converting this to question.

Hope this helps.

Thanks for understanding!

Changed in openobject-addons:
status: New → Invalid
Revision history for this message
Javier Castillo (javier-castillo) wrote :

Hello Amit,

It's not for the same period of old timesheet, it's for a new timesheet that the timesheet line is expected to be created, and this is not happening.

I'm sorry if I wasn't clear on this but I still consider this to be a bug because new added work to a task should create timesheet lines for the current draft timesheet and this is not working if the task has already work associated to an old timesheet.

I hope I explained myself better this time.

Thanks.

Changed in openobject-addons:
status: Invalid → New
Changed in openobject-addons:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → OpenERP R&D Addons Team 1 (openerp-dev-addons1)
Revision history for this message
Laurent Urbain (Realdolmen) (laurent-urbain) wrote :

Bug is on 6.1 and Trunk

Changed in openobject-addons:
status: Confirmed → In Progress
Changed in openobject-addons:
status: In Progress → Confirmed
Revision history for this message
Amit Bhavsar (Open ERP) (amb-openerp) wrote :

Hello,

Follow the step for reproduce this Bug.

1. create two timesheet with different week.(one with open state and other with Waiting for Approve state)
2. Now create task work line.
3. Try to save this : warning occured

Expected Result : task should be link with the open timesheet. not updating the old ones.

Also I have attached the video for brief Info.

Thanks!

Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
Vijaykumar Baladaniya (OpenERP) (vba) wrote :

Hello,

    Regarding this bug the problem is due to web client one2many field, When going to save the created a work line, it sending all ids instead of newly created. because of work_ids one2many field check condition every time for all related ids.

Thanks.

Changed in openobject-addons:
status: In Progress → Confirmed
affects: openobject-addons → openerp-web
Changed in openerp-web:
assignee: OpenERP R&D Addons Team 1 (openerp-dev-addons1) → nobody
assignee: nobody → Vijaykumar Baladaniya (vba)
assignee: Vijaykumar Baladaniya (vba) → nobody
Amit Parik (amit-parik)
Changed in openerp-web:
assignee: nobody → OpenERP R&D Web Team (openerp-dev-web)
Revision history for this message
Nicolas Vanhoren (OpenERP) (niv-openerp) wrote :

Ok guys, that's not a problem in o2m, that's the way it behaves. When there is a on change that set its value it will erase all data and put back new records. Please don't expect the client team to change the behavior of a core component to fit the need of a precise addon, you have to find a solution by yourselves.

affects: openerp-web → openobject-addons
Changed in openobject-addons:
assignee: OpenERP R&D Web Team (openerp-dev-web) → OpenERP R&D Addons Team 1 (openerp-dev-addons1)
Revision history for this message
Arnaud Pineux (OpenERP) (api-openerp) wrote :

Hello,

You still cannot add new line in timesheet that are 'confirmed' or 'done' but the bug is fixed.
See : lp:~openerp-dev/openobject-addons/trunk-bug-1023047-api

Good luck,

Arnaud Pineux (API)

Changed in openobject-addons:
status: Confirmed → Fix Committed
Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

the fix is not clean, I cancelled the merge proposal.
The proposed fix is quite risky as it may produces differences between what you put on tasks and what you have on timesheets. This may be confusing.

Changed in openobject-addons:
status: Fix Committed → Confirmed
status: Confirmed → Invalid
Revision history for this message
Juanjo A (juanjoa) wrote :

Hi, why the bug is invalid?

The problem exists and is important

Thx

Changed in therp-backports:
milestone: none → 7.0-maintenance
milestone: 7.0-maintenance → 6.1-maintenance
Changed in openobject-addons:
status: Invalid → Fix Committed
Changed in therp-backports:
status: New → Fix Released
Lara (Therp) (lfreeke)
Changed in therp-backports:
milestone: 6.1-maintenance → 7.0-maintenance
Changed in ocb-addons:
status: New → Fix Committed
no longer affects: therp-backports/addons-7.0
Revision history for this message
Tor Asbjørn Øvrebø (tora-o) wrote :

Any progress in this?
We are on 7.0-20130501-232419 and this is still a problem.

Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

it's fixed in ocb-addons, so consider using that instead

Revision history for this message
Michael Karrer (michaelkarrer81) wrote :

So is the fix in ocb-addons also safely working for 7.0 stable if i patch the files or could this be a problem?!?

For me this is a major bug since it blocks using the time tracking functionality fully for most customers - whats the point in time tracking if i can not confirm time sheets? Just my two cents. (YES - i would rate it high)

Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

As you can see, I also linked a branch with the patch against 7.0: https://code.launchpad.net/~therp-nl/openobject-addons/7.0_1023047

Revision history for this message
Michael Karrer (michaelkarrer81) wrote :

Sorry but i am no developer just an advanced user... and currently i have a really hard time to figure out what all those branches different trees merge proposals and so on are and mean to us. I know this does not belong to this bug but i would be VERY thank full. As far as i can see it i have four options:

1.) Still use the official 7.0 version and wait until the fix is merged into it
      -> Not really an option because time tracking is useless with this bug for us

2.) Use the 7.0 official version and Patch the file by hand
      -> Also not a good solution because we would have then to compare on every "bzr pull" the patched file with the bzr one

3.) Use the ocb-addons and ocb-server branch
      -> No idea if this is official who is doing what or if all of the bugfixes for the official 7.0 branch goes into the ocb branch as well

4.) Use the 7.0_1023047 branch
      -> honesty i dont even understand why this branch i needed?!? Is it only that the core team of openerp can review the bug before they eventually merge them?!?

Thanks for any help!

Revision history for this message
Holger Brunn (Therp) (hbrunn) wrote :

2.) only gives you problems if just the changed file is changed at that specific position. that's not very likely

Still, our (the community's) idea is just to have standard OpenERP with the bugfixes we (the community) consider important on top of it. Which is what ocb-addons is. Read that: https://launchpad.net/ocb-addons

4.) is not an option at all, don't do that.

Do your reading on https://launchpad.net/ocb-addons and post any further questions there in the answers section, I think 3.) is your way to go.

Revision history for this message
Leigh Willard (leigh) wrote :

I downloaded the stable release from late in July 2013 and this bug is still present. When will this be fixed in the stable release?

Revision history for this message
Serge (sboivin) wrote :

Fast way to solve this problem

go in project_timesheet/prohect-timesheet.py
class project_work
def write

Near the end of the function you will see that,

self.pool.get('hr.analytic.timesheet').write(cr, uid, [line_id.id], vals_line, context=context)

Change like that
if vals_line:
    self.pool.get('hr.analytic.timesheet').write(cr, uid, [line_id.id], vals_line, context=context)

Why: Openerp have only the fields {'task_id': 6} in vals, so when he build vals_line, val_line is empty and try to do a write with NO fields in, and if val_line before do the write solve the problem for us.

Revision history for this message
Carlos Almeida (cmsa) wrote :

THANKS!!
It solved the problem also in our side!!!!!!

Revision history for this message
joachim grubelnik (j-grubelnik) wrote :

hey there

this fix of serge, does not resolve the problem on our side. can anyone tell me how else we can solve this...

for me
this makes sense what javier wrote... but then the tread started to get intersting and some said this change is risky and should not be done ....
Possible fix:
--------------
To fix this issue I added this code in file project_timesheet.py, inside write function for class project_work:

            if line_id.sheet_id.state in ['confirm','done']:
                # ignore changes if timesheet is in confirm or done status
                continue

I added the lines inside the "for task" just after the line_id null verification. With this is now working for me.
--------------

but i am not a programmer ...
i just addres the if vals_line: but this makes no difference, we still cannot add some more working entries if there are already some others which has been confirmed...

hope anyone can comment something about this problem

cheers joe

Revision history for this message
joachim grubelnik (j-grubelnik) wrote :

this brings up the message
in hr_timesheet_sheet.py

    _constraints = [
        (_check_sheet_state, 'You cannot modify an entry in a Confirmed/Done timesheet !', ['state']),
    ]

so i did not really understand the if vals_line solution... but maybe i just do not fully understand the interwork of those modules

Revision history for this message
joachim grubelnik (j-grubelnik) wrote :

forgot to add the versions
bzr revno --> addons 9356
bzr revno --> server 5046
bzr revno --> web 4011

so it seems the changes we made are not for the version we have and some additional things are todo right ?

Please help on this issue

Revision history for this message
joachim grubelnik (j-grubelnik) wrote :

Hello !

It seems the problem is FIXED and the discribed FIX solved the problem.

i had a spacing problem in the if and therefore a strange thing happened,
i did not get any error message at all.

However it works now, so my other 3 comments could be deleted ... for not confusing others ....

cheers joe

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Joachim, thanks for confirming that the fix does indeed work for you!

tags: added: project timesheet
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

Issue 366 created on github https://github.com/odoo/odoo/issues/366

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.