[IMP] resource: improve ugly code in conversion function
bzr revid: rco@openerp.com-20121210090554-fb59bzz5ceogehms
This commit is contained in:
parent
7f1d5daf2f
commit
590add54d4
|
@ -274,13 +274,10 @@ class resource_calendar_attendance(osv.osv):
|
||||||
}
|
}
|
||||||
resource_calendar_attendance()
|
resource_calendar_attendance()
|
||||||
|
|
||||||
def convert_timeformat(time_string):
|
def hours_time_string(hours):
|
||||||
split_list = str(time_string).split('.')
|
""" convert a number of hours (float) into a string with format '%H:%M' """
|
||||||
hour_part = split_list[0]
|
minutes = int(round(hours * 60))
|
||||||
mins_part = split_list[1]
|
return "%02d:%02d" % divmod(minutes, 60)
|
||||||
round_mins = int(round(float(mins_part) * 60,-2))
|
|
||||||
converted_string = hour_part + ':' + str(round_mins)[0:2]
|
|
||||||
return converted_string
|
|
||||||
|
|
||||||
class resource_resource(osv.osv):
|
class resource_resource(osv.osv):
|
||||||
_name = "resource.resource"
|
_name = "resource.resource"
|
||||||
|
@ -390,8 +387,8 @@ class resource_resource(osv.osv):
|
||||||
wk_days[week['dayofweek']] = week_days[week['dayofweek']]
|
wk_days[week['dayofweek']] = week_days[week['dayofweek']]
|
||||||
else:
|
else:
|
||||||
raise osv.except_osv(_('Configuration Error!'),_('Make sure the Working time has been configured with proper week days!'))
|
raise osv.except_osv(_('Configuration Error!'),_('Make sure the Working time has been configured with proper week days!'))
|
||||||
hour_from_str = convert_timeformat(week['hour_from'])
|
hour_from_str = hours_time_string(week['hour_from'])
|
||||||
hour_to_str = convert_timeformat(week['hour_to'])
|
hour_to_str = hours_time_string(week['hour_to'])
|
||||||
res_str = hour_from_str + '-' + hour_to_str
|
res_str = hour_from_str + '-' + hour_to_str
|
||||||
wktime_list.append((day, res_str))
|
wktime_list.append((day, res_str))
|
||||||
# Convert into format like [('mon', '8:00-12:00', '13:00-18:00')]
|
# Convert into format like [('mon', '8:00-12:00', '13:00-18:00')]
|
||||||
|
|
Loading…
Reference in New Issue