Odoo Help


OpenERP 7 How to null check ? [Closed]

on 4/19/13, 1:00 AM 3,085 views

The Question has been closed

on 04/22/2013 04:53:52

below shows my source code fragment.i need to check if null values returns from both functions.?

1.when i use fresh DB then bpl_worker will empty & then its return getitem error.i added coalesce keyword also but result same (function 1)

2.when i use fresh DB then bpl.company.define table will empty and its also return error.how to check null in that type function.? (function 2)

i tried with below code.but result same

if no_define_object_no[0].current_no :

please advice me on this.all times when i use new DB i have to face that issue

def _max_reg_no(self, cr, uid, context=None):
    select coalesce(register_no, 'W00001') as reg_no
    from bpl_worker
    where id in (select max(id) from bpl_worker)
    if cr:
        res = cr.fetchone()[0]
        emp_no = str(res)
        emp_int = emp_no[1:6]
        emp_no_int = int(emp_int)
        result = 'W' + (str(emp_no_int + 1).zfill(4))
        return result

def on_change_division(self, cr, uid, ids, division_id, context=None):
    if division_id:
        division_object = self.pool.get('bpl.division.n.registration')
        division_browse = division_object.browse(cr, uid, division_id, context=context)
        result_division_id = division_browse.id
        search_condition = [
                          ('department_id', '=', result_division_id)
        no_define_object = self.pool.get('bpl.company.define')
        no_define_id = no_define_object.search(cr, uid, search_condition, context=context)
        no_define_object_no = no_define_object.browse(cr, uid, no_define_id, context=context)
        return {'value': {'emp_no': no_define_object_no[0].current_no }}

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 




Sudhir Arya
ERP Harbor Consulting Services
Sudhir Arya (ERP Harbor Consulting Services)
On 4/19/13, 3:10 AM

Try this code:

emp_no = no_define_object_no and no_define_object_no[0].current_no or False
return {'value': {'emp_no':  emp_no}}

thanks Arya its worked.wat about sql query null checking.? (my 1st function.)

on 4/19/13, 5:03 AM

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

0 follower(s)


Asked: 4/19/13, 1:00 AM
Seen: 3085 times
Last updated: 3/16/15, 8:10 AM