res_store.py 687 B

123456789101112131415161718192021222324252627282930
  1. # -*- coding: utf-8 -*-
  2. from openerp.http import request
  3. _MODEL = 'res.store'
  4. '''
  5. '''
  6. def get_stores(company_id=None):
  7. domain = []
  8. if company_id:
  9. domain.append(('company_id', '=', company_id))
  10. store_obj = request.env[_MODEL]
  11. store_ids = store_obj.search(domain)
  12. return [{
  13. 'id': store.id,
  14. 'name': store.display_name,
  15. 'parent': {
  16. 'id': store.parent_id.id or None
  17. },
  18. 'company': {
  19. 'id': store.company_id.id or None
  20. },
  21. 'journals': [{
  22. 'id': journal.id,
  23. 'name': journal.display_name
  24. } for journal in store.journal_ids]
  25. } for store in store_ids]