# -*- coding: utf-8 -*- from openerp.http import request as r def get_product_brand(): validate = ''' SELECT EXISTS( SELECT table_name FROM information_schema.columns WHERE table_schema='public' AND table_name='product_brand') ''' query = ''' SELECT id, name FROM product_brand ''' r.cr.execute(validate) for j in r.cr.fetchall(): band = j[0] if band == True: r.cr.execute(query) return [ { 'id': j[0], 'name': j[1], } for j in r.cr.fetchall() ] else: return []