From 73f7a2ba35e21d60ef98fe8ad5f2a9d735afe196 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 25 Nov 2014 12:33:28 +0100 Subject: [PATCH] [FIX] project_timesheet: date of created analytic line not in user tz When the user was in timezone UTC + 1, and added a project.task.work which created an analytic entry line (timsheet activity), if the datetime was set to 11/25 00:00:00, the date on the analytic line was set to 11/24, because this was the truncated stored value(UTC Time), which was 11/24 23:00:00 --- addons/project_timesheet/project_timesheet.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py index 6cbb4e8cf01..3b5bbae7ff1 100644 --- a/addons/project_timesheet/project_timesheet.py +++ b/addons/project_timesheet/project_timesheet.py @@ -120,7 +120,9 @@ class project_work(osv.osv): vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] if vals.get('date'): - vals_line['date' ] = vals['date'][:10] + timestamp = datetime.datetime.strptime(vals['date'], tools.DEFAULT_SERVER_DATETIME_FORMAT) + ts = fields.datetime.context_timestamp(cr, uid, timestamp, context) + vals_line['date'] = ts.strftime(tools.DEFAULT_SERVER_DATE_FORMAT) # Calculate quantity based on employee's product's uom vals_line['unit_amount'] = vals['hours']