From 22acc5d379ecec68f2c5148096aaa274f1bd6097 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 25 Feb 2015 18:26:04 +0100 Subject: [PATCH] [FIX] project_timesheet: retrocompatibility for 73f7a2ba35e21d60ef98fe8ad5f2a9d735afe196 It looks like it was possible to pass vals['date'] in date format (!= datetime format) to _create_analytic_entries. This rev. is a retrocompatible patch for 73f7a2ba35e21d60ef98fe8ad5f2a9d735afe196. In addition, it solves the same issue than the rev. 73f7a2ba35e21d60ef98fe8ad5f2a9d735afe196, but in the case the project is set on the task after the work hours are created. See ab5ecef476b82c7e00dbd1868de19832ac044f15 opw-628729 --- addons/project_timesheet/project_timesheet.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py index 2b04a1a4de3..cefb1e0ef40 100644 --- a/addons/project_timesheet/project_timesheet.py +++ b/addons/project_timesheet/project_timesheet.py @@ -118,9 +118,12 @@ class project_work(osv.osv): vals_line['user_id'] = vals['user_id'] vals_line['product_id'] = result['product_id'] if vals.get('date'): - 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) + if len(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) + else: + vals_line['date'] = vals['date'] # Calculate quantity based on employee's product's uom vals_line['unit_amount'] = vals['hours'] @@ -263,7 +266,7 @@ class task(osv.osv): missing_analytic_entries[task_work.id] = { 'name' : task_work.name, 'user_id' : task_work.user_id.id, - 'date' : task_work.date and task_work.date[:10] or False, + 'date' : task_work.date, 'account_id': acc_id, 'hours' : task_work.hours, 'task_id' : task_obj.id