just simple modify your sequence by this :
def _get_prefix_suffix(self):
def _interpolate(s, d):
return (s % d) if s else ''
def _int_to_roman(input):
ints = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
nums = ('M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I')
result = ""
for i in range(len(ints)):
count = int(input / ints[i])
result += nums[i] * count
input -= ints[i] * count
return result
def _interpolation_dict():
now = range_date = effective_date = datetime.now(pytz.timezone(self._context.get('tz') or 'UTC'))
if self._context.get('ir_sequence_date'):
effective_date = datetime.strptime(self._context.get('ir_sequence_date'), '%Y-%m-%d')
if self._context.get('ir_sequence_date_range'):
range_date = datetime.strptime(self._context.get('ir_sequence_date_range'), '%Y-%m-%d')
sequences = {
'ryear': '%Y', 'rmonth': '%m','year': '%Y', 'month': '%m', 'day': '%d', 'y': '%y', 'doy': '%j', 'woy': '%W',
'weekday': '%w', 'h24': '%H', 'h12': '%I', 'min': '%M', 'sec': '%S'
}
res = {}
for key, format in sequences.items():
if key in ['ryear', 'rmonth']:
res[key] = _int_to_roman(int(effective_date.strftime(format)))
res['range_' + key] = _int_to_roman(int(range_date.strftime(format)))
res['current_' + key] =_int_to_roman(int(now.strftime(format)))
else:
res[key] = effective_date.strftime(format)
res['range_' + key] = range_date.strftime(format)
res['current_' + key] = now.strftime(format)
return res
..show all:.
.
just simple modify your sequence by this :
def _get_prefix_suffix(self):
def _interpolate(s, d):
return (s % d) if s else ''
def _int_to_roman(input):
ints = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
nums = ('M', 'CM', 'D', 'CD','C', 'XC','L','XL','X','IX','V','IV','I')
result = ""
for i in range(len(ints)):
count = int(input / ints[i])
result += nums[i] * count
input -= ints[i] * count
return result
def _interpolation_dict():
now = range_date = effective_date = datetime.now(pytz.timezone(self._context.get('tz') or 'UTC'))
if self._context.get('ir_sequence_date'):
effective_date = datetime.strptime(self._context.get('ir_sequence_date'), '%Y-%m-%d')
if self._context.get('ir_sequence_date_range'):
range_date = datetime.strptime(self._context.get('ir_sequence_date_range'), '%Y-%m-%d')
sequences = {
'ryear': '%Y', 'rmonth': '%m','year': '%Y', 'month': '%m', 'day': '%d', 'y': '%y', 'doy': '%j', 'woy': '%W',
'weekday': '%w', 'h24': '%H', 'h12': '%I', 'min': '%M', 'sec': '%S'
}
res = {}
for key, format in sequences.items():
if key in ['ryear', 'rmonth']:
res[key] = _int_to_roman(int(effective_date.strftime(format)))
res['range_' + key] = _int_to_roman(int(range_date.strftime(format)))
res['current_' + key] =_int_to_roman(int(now.strftime(format)))
else:
res[key] = effective_date.strftime(format)
res['range_' + key] = range_date.strftime(format)
res['current_' + key] = now.strftime(format)
return res
No comments:
Post a Comment