123456789101112131415161718192021222324252627282930313233343536 |
- # -*- coding: utf-8 -*-
- from openerp import http
- from werkzeug.wrappers import Response
- from werkzeug.datastructures import Headers
- from gzip import GzipFile
- from StringIO import StringIO as IO
- import simplejson as json
- import helpers as hp
- import logging
- LOGGER = logging.getLogger(__name__)
- GZIP_COMPRESSION_LEVEL = 9
- def make_gzip_response(data=None, status=200):
- gzip_buffer = IO()
- with GzipFile(mode='wb', compresslevel=GZIP_COMPRESSION_LEVEL, fileobj=gzip_buffer) as gzip_file:
- gzip_file.write(json.dumps(data))
- value = gzip_buffer.getvalue()
- gzip_buffer.close()
- headers = Headers()
- headers.add('Content-Encoding', 'gzip')
- headers.add('Vary', 'Accept-Encoding')
- headers.add('Content-Length', len(value))
- return Response(value, status=status, headers=headers, content_type='application/json')
- class ReportMoconaController(http.Controller):
- @http.route('/report-budgetdental-analytic', auth='user', methods=['GET', 'POST'])
- def getSaleBudget(self, **kw):
- return make_gzip_response({
- 'order_lines': hp.get_sale_order_line(),
- })
|