company.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request as r
  3. def get_company_info():
  4. user_company = r.env.user.company_id.id
  5. user_store = r.env.user.store_id.id
  6. query = '''
  7. SELECT
  8. company.id,
  9. company.name,
  10. currency.id,
  11. currency.name,
  12. currency.symbol,
  13. currency.decimal_places,
  14. currency.decimal_separator,
  15. currency.thousands_separator,
  16. currency.symbol_position,
  17. store.name AS store,
  18. partner.ruc AS company_ruc
  19. FROM res_company AS company
  20. LEFT JOIN res_currency AS currency
  21. ON company.currency_id = currency.id
  22. LEFT JOIN res_store AS store
  23. ON store.id = ''' + str(user_store) + '''
  24. LEFT JOIN res_partner AS partner
  25. ON partner.id = company.partner_id
  26. WHERE currency.active = true
  27. AND company.id = ''' + str(user_company) + '''
  28. '''
  29. r.cr.execute(query)
  30. return [
  31. {
  32. 'id': j[0],
  33. 'name': j[1],
  34. 'currency_id':{
  35. 'id': j[2],
  36. 'name': j[3],
  37. 'symbol': j[4],
  38. 'decimal_places': j[5],
  39. 'decimal_separator': j[6],
  40. 'thousands_separator': j[7],
  41. 'symbol_position': j[8],
  42. },
  43. 'store': j[9],
  44. 'ruc': j[10],
  45. } for j in r.cr.fetchall()
  46. ]