跳至內容
選單
此問題已被標幟
2 回覆
24961 瀏覽次數

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
7355
1
6月 20
4716
1
5月 25
797
0
1月 24
1562
2
5月 23
8435