Odoo Help


How to verify that a field date is empty?

on 7/15/13, 9:15 AM 10,248 views

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.

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

on 7/19/13, 9:33 AM
ainur rofiq
On 7/16/13, 4:24 PM

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.

Adrian Merrall
on 7/17/13, 12:49 AM

thank you for more explation

KAM, ainur rofiq
on 7/17/13, 1:29 AM

thank you for your response I’ll try it

on 7/19/13, 9:16 AM

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

on 7/19/13, 9:32 AM

AJ Schrafel Paper Corp

--AJ Schrafel Paper Corp--
| 4 5 8
Bronx, United States
--AJ Schrafel Paper Corp--

Exploring OpenERP for business

AJ Schrafel Paper Corp
On 7/16/13, 4:51 PM
if variable == None:
  your code here

that didn't work

on 7/19/13, 9:44 AM
On 7/19/13, 9:34 AM

I have found the solution it was simply

if (field_date==False):

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/15/13, 9:15 AM
Seen: 10248 times
Last updated: 3/16/15, 8:10 AM