diff --git a/date_range/wizard/date_range_generator.py b/date_range/wizard/date_range_generator.py index 919b07b5e..970af6b71 100644 --- a/date_range/wizard/date_range_generator.py +++ b/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,