콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
23146 화면

Hello All,

I want to change invoice sequence number like Inv/assessment year(AY)/Monthname/0001

For Example Inv/19-20/July/0001

I have follow below step to achive this things

Setting-->Technical-->Sequences&identifiers-->Sequence and search invoice.

Modified prefix as Inv/%(year)s/%(month)s/ and I got the new invoice number as Inv/2019/07/0001 but I want to invoice number as Inv/19-20/July/0001

Thanks in advance

Ankit H Gandhi

아바타
취소
작성자 베스트 답변

Hello All,

I found this solution using re-define method of _get_prefix_suffix

def _get_prefix_suffix(self):
def _interpolate(s, d):
return (s % d) if s else ''

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 = fields.Datetime.from_string(self._context.get('ir_sequence_date'))
if self._context.get('ir_sequence_date_range'):
range_date = fields.Datetime.from_string(self._context.get('ir_sequence_date_range'))

sequences = {
'year': '%Y', 'month': '%m', 'day': '%d', 'y': '%y', 'doy': '%j', 'woy': '%W',
'weekday': '%w', 'h24': '%H', 'h12': '%I', 'min': '%M', 'sec': '%S'
}
if range_date:
ay = str(range_date.year)[2:] + '-' + \
str(range_date.year + 1)[2:]
sequences.update({'ay': ay, 'month_text': '%B'})
res = {}
for key, format in sequences.items():
res[key] = effective_date.strftime(format)
res['range_' + key] = range_date.strftime(format)
res['current_' + key] = now.strftime(format)

return res

d = _interpolation_dict()
try:
interpolated_prefix = _interpolate(self.prefix, d)
interpolated_suffix = _interpolate(self.suffix, d)
except ValueError:
raise UserError(_('Invalid prefix or suffix for sequence \'%s\'') % (self.get('name')))
return interpolated_prefix, interpolated_suffix
Then Go to 
Setting-->Technical-->Sequences&identifiers-->Sequence and search invoice.

Change Prefix to: Inv/%(ay)s/%(month_text)s/

Appreciate to Mitul Shingala and OdooTools

Best Regards,

Ankit H Gandhi.


아바타
취소

I am using Odoo 13 and I would like to use this code to implement the fiscal year range into my invoice. Could you guide me how to locate the ir.sequence model and the adjusting the code to reflect the changes in the invoice.

베스트 답변

Available suffixes' and prefixes' legends are available right on the sequence form:

  • Current Year with Century: %(year)s

  • Current Year without Century: %(y)s (in your case '19', centure alone is not available) 

  • Month: %(month)s (only number, textual representation is not available)

  • Day: %(day)s

  • Day of the Year: %(doy)s

  • Week of the Year: %(woy)s

  • Day of the Week (0:Monday): %(weekday)s

  • Hour 00->24: %(h24)s

  • Hour 00->12: %(h12)s

  • Minute: %(min)s

  • Second: %(sec)s

As you can see those standard legends can not help to achieve your goals.

You should add a bit of coding to re-define the method '_get_prefix_suffix' of the model ir.sequence (the module 'base') by adding extra legends expressions.


아바타
취소
관련 게시물 답글 화면 활동
0
9월 20
2120
0
9월 18
2761
1
2월 17
2845
1
2월 24
821
3
7월 23
4267