Odoo Help
Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM
|
e-Commerce
|
Accounting
|
Inventory
|
PoS
|
Project management
|
MRP
|
etc.
OpenERP 7 How to null check ? [Closed]
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):
cr.execute("""
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 }}
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.)
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.
RegisterOdoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.
Test it nowQuestion tools
Stats
Asked: 4/19/13, 1:00 AM |
Seen: 2996 times |
Last updated: 3/16/15, 8:10 AM |