Skip to content

Commit

Permalink
[FIX] project_timesheet: retrocompatibility for 73f7a2b
Browse files Browse the repository at this point in the history
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 73f7a2b.

In addition, it solves the same issue than the rev.
73f7a2b, but in the case the project is
set on the task after the work hours are created.
See ab5ecef

opw-628729
  • Loading branch information
beledouxdenis committed Feb 25, 2015
1 parent 37f9459 commit 22acc5d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions addons/project_timesheet/project_timesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ def _create_analytic_entries(self, cr, uid, vals, context):
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']
Expand Down Expand Up @@ -263,7 +266,7 @@ def write(self, cr, uid, ids, vals, context=None):
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
Expand Down

0 comments on commit 22acc5d

Please sign in to comment.