product_brand.py 727 B

123456789101112131415161718192021222324252627282930313233
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request as r
  3. def get_product_brand():
  4. validate = '''
  5. SELECT EXISTS(
  6. SELECT table_name
  7. FROM information_schema.columns
  8. WHERE table_schema='public'
  9. AND table_name='product_brand')
  10. '''
  11. query = '''
  12. SELECT
  13. id,
  14. name
  15. FROM product_brand
  16. '''
  17. r.cr.execute(validate)
  18. for j in r.cr.fetchall():
  19. band = j[0]
  20. if band == True:
  21. r.cr.execute(query)
  22. return [
  23. {
  24. 'id': j[0],
  25. 'name': j[1],
  26. } for j in r.cr.fetchall()
  27. ]
  28. else:
  29. return []