payments_journals.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request as r
  3. def get_payments_journals_widget():
  4. user_store = r.env.user.store_id.id
  5. query = '''
  6. SELECT
  7. journal.id,
  8. journal.name,
  9. journal.code,
  10. journal.type,
  11. journal.currency,
  12. journal_rel.store_id,
  13. currency.symbol,
  14. currency.decimal_places,
  15. currency.thousands_separator,
  16. currency.decimal_separator
  17. FROM account_journal AS journal
  18. LEFT JOIN res_store_journal_rel AS journal_rel
  19. ON journal_rel.journal_id = journal.id
  20. LEFT JOIN res_currency AS currency
  21. ON currency.id = journal.currency
  22. WHERE journal.active = true
  23. AND journal.type in ('bank', 'cash')
  24. AND journal_rel.store_id = ''' + str(user_store) + '''
  25. '''
  26. r.cr.execute(query)
  27. return [
  28. {
  29. 'id': j[0],
  30. 'name': j[1],
  31. 'code': j[2],
  32. 'type': j[3],
  33. 'currency': j[4],
  34. 'store_id': j[5],
  35. 'symbol': j[6],
  36. 'decimal_places': j[7],
  37. 'thousands_separator': j[8],
  38. 'decimal_separator': j[9],
  39. } for j in r.cr.fetchall()
  40. ]