İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
25571 Görünümler

Hello,

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


Thank You

Avatar
Vazgeç
Üretici

yes, it's works

Thanks zbik

En İyi Yanı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)    

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Eyl 21
7901
1
Haz 20
5194
3
Tem 25
9543
1
May 25
1758
0
Oca 24
2378