Odoo Help

Welcome!

This community 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.

0

How to verify that a field date is empty?

By
ZEeineb
on 7/15/13, 9:15 AM 4,861 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):

ZEeineb
on 7/19/13, 9:33 AM
1
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

ZEeineb
on 7/19/13, 9:16 AM

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

ZEeineb
on 7/19/13, 9:32 AM
0

AJ Schrafel Paper Corp

--AJ Schrafel Paper Corp--
2050
| 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

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

I have found the solution it was simply

if (field_date==False):

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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