Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
24985 มุมมอง

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)    

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ย. 21
7369
1
มิ.ย. 20
4732
3
ก.ค. 25
8528
1
พ.ค. 25
832
0
ม.ค. 24
1603