Weekly timesheet created on monday covers two weeks

Bug #897662 reported by Stefan Rijnhart (Opener)
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Fix Released
Medium
OpenERP R&D Addons Team 3

Bug Description

Hi,

Set the company's timesheet range to 'Week'. Create a timesheet on Monday. The new timesheet covers a period of two weeks, starting from the Monday a week before.

Culprit is (datetime.today() + relativedelta(weekday=0, weeks=-1) in hr_timesheet_sheet/hr_timesheet_sheet.py:hr_timesheet_sheet.default_date_to().

>>> from datetime import datetime
>>> from dateutil.relativedelta import relativedelta
>>> datetime(2011, 11, 28, 13, 38, 3, 560694) + relativedelta(weekday=0, weeks=-1)
datetime.datetime(2011, 11, 21, 13, 38, 3, 560694)

Instead, use (datetime.today() + relativedelta(weekday=0, days=-6).

>>> datetime(2011, 11, 28, 13, 38, 3, 560694) + relativedelta(weekday=0, days=-6)
datetime.datetime(2011, 11, 28, 13, 38, 3, 560694)

Reproducable in 6.0 and trunk.

Cheers,
Stefan.

Related branches

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

Hello Stefan,

I have checked your issue with latest stable and trunk both, but all are working fine.

I have attached a video for your reference so would you please check it and notify us where you faced the problem.

Thanks and waiting for your reply!

Revision history for this message
Amit Parik (amit-parik) wrote :
Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Amit,

well, maybe I was not clear enough but the bug only occurs when you create a timesheet on Monday! You created a timesheet on Wednesday and then it works as expected.

The reason for this is that the relativedelta in the code selects the first Monday from today() a week ago. On a Monday, the result is Monday last week. On a Wednesday, the result is last Monday.

Cheers,
Stefan.

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

Hello Stefan,

Thanks for your reply!

I have faced the same problem when I have creates a timesheet from Monday.

I have attached a video for more reference.

Thank you!

Revision history for this message
Amit Parik (amit-parik) wrote :
Changed in openobject-addons:
assignee: nobody → OpenERP R&D Addons Team 3 (openerp-dev-addons3)
importance: Undecided → Medium
status: Incomplete → Confirmed
Changed in openobject-addons:
status: Confirmed → In Progress
Revision history for this message
DJ Patel (OpenERP) (mdi-openerp) wrote :

Hello Stefan Rijnhart,

Thanks for reporting and also for giving suggestion. The solution for this bug is proposed in the branch : https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-897662-mdi/

with following Revision ID and Number.

Revision ID : <email address hidden>
Revision Number : 5896

Thanks and Regards,

Divyesh Makwana(MDI)

Changed in openobject-addons:
status: In Progress → Fix Committed
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Divyesh and Amit,

many thanks for working on this and for crediting me as the author of the branch ;-)

Cheers,
Stefan.

Changed in openobject-addons:
milestone: none → 6.1
Revision history for this message
Raphael Collet (OpenERP) (rco-openerp) wrote :

landed in trunk
revno: 6001
revision-id: <email address hidden>

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