summaryrefslogtreecommitdiff
path: root/addons/web/controllers/pivot.py
diff options
context:
space:
mode:
authorfwi-odoo <fwi@odoo.com>2016-07-20 15:00:17 +0200
committerThibault Delavallée <tde@openerp.com>2016-08-03 13:42:00 +0200
commit7d487c00a679980b96409e261322f93ba3e340f2 (patch)
tree4a017a46ec06c40f4d8185ef7ae09f9108c4aaed /addons/web/controllers/pivot.py
parent1feae7447f82c68934baacb7bef0c0c358038e8b (diff)
[IMP] web: remove void file, replace openerp tags, add license, clean imports
Diffstat (limited to 'addons/web/controllers/pivot.py')
-rw-r--r--addons/web/controllers/pivot.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/addons/web/controllers/pivot.py b/addons/web/controllers/pivot.py
index 571cff94229..97fc1d4eb83 100644
--- a/addons/web/controllers/pivot.py
+++ b/addons/web/controllers/pivot.py
@@ -1,21 +1,24 @@
-from openerp import http
-import json
-from openerp.http import request, serialize_exception as _serialize_exception
-from cStringIO import StringIO
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
from collections import deque
+import json
+
+from odoo import http
+from odoo.http import request
try:
import xlwt
except ImportError:
xlwt = None
+
class TableExporter(http.Controller):
@http.route('/web/pivot/check_xlwt', type='json', auth='none')
def check_xlwt(self):
return xlwt is not None
-
@http.route('/web/pivot/export_xls', type='http', auth="user")
def export_xls(self, data, token):
jdata = json.loads(data)
@@ -29,41 +32,41 @@ class TableExporter(http.Controller):
# Step 1: writing headers
headers = jdata['headers']
- # x,y: current coordinates
+ # x,y: current coordinates
# carry: queue containing cell information when a cell has a >= 2 height
# and the drawing code needs to add empty cells below
- x, y, carry = 1, 0, deque()
+ x, y, carry = 1, 0, deque()
for i, header_row in enumerate(headers):
- worksheet.write(i,0, '', header_plain)
+ worksheet.write(i, 0, '', header_plain)
for header in header_row:
while (carry and carry[0]['x'] == x):
cell = carry.popleft()
for i in range(nbr_measures):
worksheet.write(y, x+i, '', header_plain)
if cell['height'] > 1:
- carry.append({'x': x, 'height':cell['height'] - 1})
+ carry.append({'x': x, 'height': cell['height'] - 1})
x = x + nbr_measures
style = header_plain if 'expanded' in header else header_bold
for i in range(header['width']):
worksheet.write(y, x + i, header['title'] if i == 0 else '', style)
if header['height'] > 1:
- carry.append({'x': x, 'height':header['height'] - 1})
- x = x + header['width'];
+ carry.append({'x': x, 'height': header['height'] - 1})
+ x = x + header['width']
while (carry and carry[0]['x'] == x):
cell = carry.popleft()
for i in range(nbr_measures):
worksheet.write(y, x+i, '', header_plain)
if cell['height'] > 1:
- carry.append({'x': x, 'height':cell['height'] - 1})
+ carry.append({'x': x, 'height': cell['height'] - 1})
x = x + nbr_measures
x, y = 1, y + 1
# Step 2: measure row
if nbr_measures > 1:
- worksheet.write(y,0, '', header_plain)
+ worksheet.write(y, 0, '', header_plain)
for measure in jdata['measure_row']:
style = header_bold if measure['is_bold'] else header_plain
- worksheet.write(y, x, measure['measure'], style);
+ worksheet.write(y, x, measure['measure'], style)
x = x + 1
y = y + 1