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

Hello,

How to set default value from function for fields Date in V8?


Thank You

아바타
취소
작성자

yes, it's works

Thanks zbik

베스트 답변

For example:

@api.model
def _default_date(self):
  inv_type = self._context.get('type', 'out_invoice')
  if inv_type == 'out_invoice':
     current_date = time.strftime(DEFAULT_SERVER_DATE_FORMAT)
     return current_date
date_invoice = fields.Date(string='Invoice Date',readonly=True, states={'draft': [('readonly', False)]}, index=True, help="Keep empty to use the current date", copy=False, default=_default_date)    

아바타
취소
관련 게시물 답글 화면 활동
2
9월 21
7708
1
6월 20
5014
3
7월 25
9314
1
5월 25
1512
0
1월 24
2130