res_company.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request as r
  3. def get_res_company():
  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. partner.ruc AS company_ruc
  18. FROM res_company AS company
  19. LEFT JOIN res_currency AS currency
  20. ON company.currency_id = currency.id
  21. LEFT JOIN res_partner AS partner
  22. ON partner.id = company.partner_id
  23. WHERE currency.active = true
  24. '''
  25. r.cr.execute(query)
  26. return [
  27. {
  28. 'id': j[0],
  29. 'name': j[1],
  30. 'currency_id':{
  31. 'id': j[2],
  32. 'name': j[3],
  33. 'symbol': j[4],
  34. 'decimal_places': j[5],
  35. 'decimal_separator': j[6],
  36. 'thousands_separator': j[7],
  37. 'symbol_position': j[8],
  38. },
  39. 'ruc': j[9],
  40. } for j in r.cr.fetchall()
  41. ]