Browse Source

date_range: code fine tuning suggested by Sylvain Garancher

pull/3/head
Alexis de Lattre 8 years ago
committed by Laurent Mignon (ACSONE)
parent
commit
572f55d9ce
  1. 7
      date_range/wizard/date_range_generator.py

7
date_range/wizard/date_range_generator.py

@ -43,7 +43,7 @@ class DateRangeGenerator(models.TransientModel):
count=self.count+1)
vals = list(vals)
date_ranges = []
month_digits = len(unicode(self.count))
count_digits = len(unicode(self.count))
for idx, dt_start in enumerate(vals[:-1]):
date_start = fields.Date.to_string(dt_start.date())
# always remove 1 day for the date_end since range limits are
@ -51,9 +51,8 @@ class DateRangeGenerator(models.TransientModel):
dt_end = vals[idx+1].date() - relativedelta(days=1)
date_end = fields.Date.to_string(dt_end)
date_ranges.append({
'name': '%s%s' % (
self.name_prefix,
unicode(idx + 1).zfill(month_digits)),
'name': '%s%0*d' % (
self.name_prefix, count_digits, idx + 1),
'date_start': date_start,
'date_end': date_end,
'type_id': self.type_id.id,

Loading…
Cancel
Save