# -*- coding: utf-8 -*-
+
import ast
import base64
import csv
import glob
import itertools
+import logging
import operator
import datetime
import hashlib
xlwt = None
import openerp
+import openerp.modules.registry
from openerp.tools.translate import _
from .. import http
if reader is None:
def reader(f):
- with open(f, 'rb') as fp:
- return fp.read()
+ import codecs
+ with codecs.open(f, 'rb', "utf-8-sig") as fp:
+ return fp.read().encode("utf-8")
files_content = []
for fname in file_list:
else:
try:
# create an empty registry
- registry = openerp.modules.registry.Registry(dbname.lower())
+ registry = openerp.modules.registry.Registry(dbname)
with registry.cursor() as cr:
cr.execute("""SELECT c.logo_web
FROM res_users u
else:
return False
-
class Export(openerpweb.Controller):
_cp_path = "/web/export"
(prefix + '/' + k, prefix_string + '/' + v)
for k, v in self.fields_info(req, model, export_fields).iteritems())
-
class ExportFormat(object):
- """
- Superclass for export formats, should probably be an abc and have a way to
- generate _cp_path from fmt but it's a pain to deal with conflicts with
- ControllerType
- """
@property
def content_type(self):
""" Provides the format's content type """
else:
columns_headers = [val['label'].strip() for val in fields]
+
return req.make_response(self.from_data(columns_headers, import_data),
headers=[('Content-Disposition',
content_disposition(self.filename(model), req)),
('Content-Type', self.content_type)],
cookies={'fileToken': int(token)})
-
class CSVExport(ExportFormat, http.Controller):
_cp_path = '/web/export/csv'
fmt = {'tag': 'csv', 'label': 'CSV'}
fp.close()
return data
-
class ExcelExport(ExportFormat, http.Controller):
_cp_path = '/web/export/xls'
fmt = {
fp.close()
return data
-
class Reports(openerpweb.Controller):
_cp_path = "/web/report"
POLLING_DELAY = 0.25