تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
25373 أدوات العرض

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
سبتمبر 21
7727
1
يونيو 20
5033
3
يوليو 25
9354
1
مايو 25
1552
0
يناير 24
2153