123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- # -*- 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 ReportController(http.Controller):
- # CONSULTA INICIAL
- @http.route('/report-filter-data-inmobiliaria', auth='user', methods=['GET', 'POST'])
- def getFilterData(self, **kw):
- return make_gzip_response({
- 'companies': hp.get_res_company_inmobiliaria(),
- 'logo': hp.get_company_logo_inmobiliaria(),
- 'stores': hp.get_res_store_inmobiliaria(),
- 'journals': hp.get_account_journal_inmobiliaria(),
- 'users': hp.get_res_users_inmobiliaria(),
- 'partner':hp.get_res_partner_inmobiliaria(),
- 'supplier':hp.get_supplier_inmobiliaria(),
- 'property_state': hp.get_property_state_inmobiliaria(),
- })
- # CONTRATOS
- @http.route('/report-contracts-inmobiliaria', auth='user', methods=['GET', 'POST'])
- def getContracts(self, **kw):
- return make_gzip_response({
- 'contracts': hp.get_contracts_inmobiliaria(),
- 'partners': hp.get_res_partner_inmobiliaria(),
- })
- #COMISIONES
- @http.route('/report-sale-history-inmobiliaria', auth='user', methods=['GET', 'POST'])
- def getSaleHistory(self, **kw):
- return make_gzip_response({
- 'invoices': hp.get_account_invoice_sale_type_inmobiliaria(),
- 'invoice_line': hp.get_account_invoice_line_out_invoice_inmobiliaria(),
- 'orders': hp.get_pos_order_inmobiliaria(),
- 'partners': hp.get_all_res_partner_inmobiliaria(),
- })
- #PROPIEDADES
- @http.route('/report-propiedades-inmobiliaria', auth='user', methods=['GET', 'POST'])
- def getProductTemplate(self, **kw):
- return make_gzip_response({
- 'template': hp.get_product_template_inmobiliaria(),
- 'supplier':hp.get_supplier_inmobiliaria(),
- })
- #VENTAS MENSUAL
- @http.route('/report-sale-inmobiliaria', auth='user', methods=['GET', 'POST'])
- def getSale(self, **kw):
- return make_gzip_response({
- 'invoices': hp.get_account_invoice_sale_type_inmobiliaria2(),
- 'invoice_line': hp.get_account_invoice_line_out_invoice_inmobiliaria(),
- 'orders': hp.get_pos_order_inmobiliaria(),
- 'partners': hp.get_res_partner_inmobiliaria(),
- 'contracts': hp.get_contracts_inmobiliaria(),
- 'contract_line': hp.get_contract_line_inmobiliaria(),
- })
|