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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Księgowość
- Zapasy
- PoS
- Project
- MRP
To pytanie dostało ostrzeżenie
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
Podoba Ci się ta dyskusja? Dołącz do niej!
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
Format language date_format '%B' in python
Rozwiązane
|
|
1
mar 17
|
28490 | |
|
2
mar 16
|
3572 | ||
odoo 16 dashboard select specific date range
Rozwiązane
|
|
3
cze 25
|
798 | |
|
0
mar 25
|
1214 | ||
|
1
sty 25
|
17746 |
I have found the solution it was simply if (field_date==False):