res_company.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. ]
  42. def get_res_company_logo():
  43. values = []
  44. for company in r.env['res.company'].search([]):
  45. values.append({
  46. 'id': company.id,
  47. 'name': company.name,
  48. 'logo': company.logo,
  49. })
  50. return values