Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
25339 Lượt xem

Hello,

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


Thank You

Ảnh đại diện
Huỷ bỏ
Tác giả

yes, it's works

Thanks zbik

Câu trả lời hay nhất

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)    

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 9 21
7690
1
thg 6 20
4988
3
thg 7 25
9278
1
thg 5 25
1492
0
thg 1 24
2114