res_company.py 1.7 KB

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