Hello, I want to make a condition if the value of a field date is null then I'll do some treatments in python code. Thank you.
Pertanyaan ini telah diberikan tanda
3
Replies
47745
Tampilan
I have found the solution it was simply
if (field_date==False):
maybe like this :
def create(self, cr, uid, vals, context=None):
if not vals['field_date']: # field_date is null/not set
vals['field_date'] = time.strftime('%Y-%m-%d')
return super(scale_material, self).create(cr, uid, vals, context=context)
This will throw a key error if field_date is not in vals. You could either do if not vals.get('field_date', False): or if not 'field_date' in vals and not vals['field_date']: Also don't forget the write method as well.
thank you for more explation
thank you for your response Iâll try it
I have found the solution it was simply if (field_date==False):
It does not work for me.
if variable == None:
your code here
that didn't work
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
Daftar| Post Terkait | Replies | Tampilan | Aktivitas | |
|---|---|---|---|---|
|
Format language date_format '%B' in python
Diselesaikan
|
|
1
Mar 17
|
30884 | |
|
|
2
Mar 16
|
5482 | ||
|
|
0
Mar 26
|
10 | ||
|
odoo 16 dashboard select specific date range
Diselesaikan
|
|
3
Jun 25
|
4277 | |
|
|
0
Mar 25
|
4439 |
I have found the solution it was simply if (field_date==False):