journal.py 704 B

123456789101112131415161718192021222324252627
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request as r
  3. def get_journals_widget():
  4. user_store = r.env.user.store_id.id
  5. query = '''
  6. SELECT aj.id, aj.name, aj.code, aj.type, rs.store_id
  7. FROM account_journal AS aj
  8. LEFT JOIN res_store_journal_rel AS rs
  9. ON aj.id = rs.journal_id
  10. WHERE aj.active = true
  11. AND aj.type in ('sale', 'purchase', 'sale_refund', 'purchase_refund')
  12. AND rs.store_id = ''' + str(user_store) + '''
  13. ORDER BY aj.id
  14. '''
  15. r.cr.execute(query)
  16. return [
  17. {
  18. 'id': j[0],
  19. 'name': j[1],
  20. 'code': j[2],
  21. 'type': j[3],
  22. 'store_id': j[4]
  23. } for j in r.cr.fetchall()
  24. ]