コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
25349 ビュー

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
7697
1
6月 20
5006
3
7月 25
9292
1
5月 25
1497
0
1月 24
2123