[FIX] project_timesheet: date of created analytic line not in user tz
authorDenis Ledoux <dle@odoo.com>
Tue, 25 Nov 2014 11:33:28 +0000 (12:33 +0100)
committerDenis Ledoux <dle@odoo.com>
Tue, 25 Nov 2014 11:33:28 +0000 (12:33 +0100)
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

index 6cbb4e8..3b5bbae 100644 (file)
@@ -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']