Migrate sql_export_excel to v12

This commit is contained in:
Florian da Costa
2019-09-02 13:06:36 +02:00
committed by Maksym Yankin
parent c9c714e0b9
commit fa75f07ede
4 changed files with 8 additions and 12 deletions

View File

@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from . import test_sql_query_excel

View File

@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2019 Akretion (<http://www.akretion.com>)
# @author: Florian da Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp.tests.common import TransactionCase
from odoo.tests.common import TransactionCase
import base64
from cStringIO import StringIO
from io import BytesIO
import logging
_logger = logging.getLogger(__name__)
@@ -25,7 +24,7 @@ class TestExportSqlQueryExcel(TransactionCase):
def get_workbook_from_query(self, wizard):
wizard.export_sql()
decoded_data = base64.b64decode(wizard.binary_file)
xlsx_file = StringIO(decoded_data)
xlsx_file = BytesIO(decoded_data)
return openpyxl.load_workbook(xlsx_file)
def test_excel_file_generation(self):
@@ -63,7 +62,7 @@ class TestExportSqlQueryExcel(TransactionCase):
ws2 = wb.create_sheet("data")
ws2.cell(row=1, column=1, value='Partner Id')
ws2.cell(row=1, column=2, value='Partner Name')
output = StringIO()
output = BytesIO()
wb.save(output)
data = output.getvalue()