[FIX] datetime.strptime only accepts date format when used with tools.DEFAULT_SERVER_DATE_FORMAT as parameter, but both date and datetime fields can be used as parameters.

bzr revid: acl@openerp.com-20140205163313-xcob4funucvsfdmx
This commit is contained in:
Anael Closson 2014-02-05 17:33:13 +01:00
parent c68c5837aa
commit 10dabcfd51
1 changed files with 2 additions and 1 deletions

View File

@ -123,8 +123,9 @@ class crm_case_section(osv.osv):
'tooltip': (month_begin + relativedelta.relativedelta(months=-i)).strftime('%B'),
} for i in range(self._period_number - 1, -1, -1)]
group_obj = obj.read_group(cr, uid, domain, read_fields, groupby_field, context=context)
pattern = tools.DEFAULT_SERVER_DATE_FORMAT if obj.fields_get(cr, uid, groupby_field)[groupby_field]['type'] == 'date' else tools.DEFAULT_SERVER_DATETIME_FORMAT
for group in group_obj:
group_begin_date = datetime.strptime(group['__domain'][0][2], tools.DEFAULT_SERVER_DATE_FORMAT)
group_begin_date = datetime.strptime(group['__domain'][0][2], pattern)
month_delta = relativedelta.relativedelta(month_begin, group_begin_date)
section_result[self._period_number - (month_delta.months + 1)] = {'value': group.get(value_field, 0), 'tooltip': group_begin_date.strftime('%B')}
return section_result