Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
45458 Vizualizări

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.

Imagine profil
Abandonează
Autor

I have found the solution it was simply if (field_date==False):

Autor Cel mai bun răspuns

I have found the solution it was simply

if (field_date==False):
Imagine profil
Abandonează
Cel mai bun răspuns

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)
Imagine profil
Abandonează

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

Autor

thank you for your response I’ll try it

Autor

I have found the solution it was simply if (field_date==False):

It does not work for me.

Cel mai bun răspuns
if variable == None:
  your code here
Imagine profil
Abandonează
Autor

that didn't work

Related Posts Răspunsuri Vizualizări Activitate
1
mar. 17
28673
2
mar. 16
3676
3
iun. 25
1050
0
mar. 25
1375
1
ian. 25
17946