Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
24976 Zobrazení

Hello,

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


Thank You

Avatar
Zrušit
Autor

yes, it's works

Thanks zbik

Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
zář 21
7365
1
čvn 20
4727
3
čvc 25
8495
1
kvě 25
817
0
led 24
1589