Browse Source
Small fixes for v12/python3 standard
Co-Authored-By: David Beal <david.beal@akretion.com>
12.0-mig-module_prototyper_last
Florian
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
8 additions and
8 deletions
-
sql_export/models/sql_export.py
-
sql_export/wizard/wizard_file.py
-
sql_export_excel/models/sql_export.py
-
sql_export_excel/tests/test_sql_query_excel.py
|
@ -59,7 +59,7 @@ class SqlExport(models.Model): |
|
|
if self.file_format == 'csv': |
|
|
if self.file_format == 'csv': |
|
|
return 'csv' |
|
|
return 'csv' |
|
|
|
|
|
|
|
|
def csv_get_datas_from_query(self, variable_dict): |
|
|
|
|
|
|
|
|
def csv_get_data_from_query(self, variable_dict): |
|
|
self.ensure_one() |
|
|
self.ensure_one() |
|
|
# Execute Request |
|
|
# Execute Request |
|
|
res = self._execute_sql_request( |
|
|
res = self._execute_sql_request( |
|
|
|
@ -70,11 +70,11 @@ class SqlFileWizard(models.TransientModel): |
|
|
|
|
|
|
|
|
# Call different method depending on file_type since the logic will be |
|
|
# Call different method depending on file_type since the logic will be |
|
|
# different |
|
|
# different |
|
|
method_name = '%s_get_datas_from_query' % sql_export.file_format |
|
|
|
|
|
datas = getattr(sql_export, method_name)(variable_dict) |
|
|
|
|
|
|
|
|
method_name = '%s_get_data_from_query' % sql_export.file_format |
|
|
|
|
|
data = getattr(sql_export, method_name)(variable_dict) |
|
|
extension = sql_export._get_file_extension() |
|
|
extension = sql_export._get_file_extension() |
|
|
self.write({ |
|
|
self.write({ |
|
|
'binary_file': datas, |
|
|
|
|
|
|
|
|
'binary_file': data, |
|
|
'file_name': '%(name)s_%(date)s.%(extension)s' % { |
|
|
'file_name': '%(name)s_%(date)s.%(extension)s' % { |
|
|
'name': sql_export.name, 'date': date, 'extension': extension} |
|
|
'name': sql_export.name, 'date': date, 'extension': extension} |
|
|
}) |
|
|
}) |
|
|
|
@ -1,7 +1,7 @@ |
|
|
# Copyright 2019 Akretion |
|
|
# Copyright 2019 Akretion |
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
|
|
|
|
|
|
|
|
from openerp import api, exceptions, fields, models, _ |
|
|
|
|
|
|
|
|
from odoo import api, exceptions, fields, models, _ |
|
|
from io import BytesIO |
|
|
from io import BytesIO |
|
|
import logging |
|
|
import logging |
|
|
import base64 |
|
|
import base64 |
|
@ -67,10 +67,10 @@ class SqlExport(models.Model): |
|
|
if self.file_format == 'excel': |
|
|
if self.file_format == 'excel': |
|
|
return 'xlsx' |
|
|
return 'xlsx' |
|
|
else: |
|
|
else: |
|
|
return super(SqlExport, self)._get_file_extension() |
|
|
|
|
|
|
|
|
return super()._get_file_extension() |
|
|
|
|
|
|
|
|
@api.multi |
|
|
@api.multi |
|
|
def excel_get_datas_from_query(self, variable_dict): |
|
|
|
|
|
|
|
|
def excel_get_data_from_query(self, variable_dict): |
|
|
self.ensure_one() |
|
|
self.ensure_one() |
|
|
res = self._execute_sql_request( |
|
|
res = self._execute_sql_request( |
|
|
params=variable_dict, mode='fetchall', header=self.header) |
|
|
params=variable_dict, mode='fetchall', header=self.header) |
|
|
|
@ -18,7 +18,7 @@ except ImportError: |
|
|
class TestExportSqlQueryExcel(TransactionCase): |
|
|
class TestExportSqlQueryExcel(TransactionCase): |
|
|
|
|
|
|
|
|
def setUp(self): |
|
|
def setUp(self): |
|
|
super(TestExportSqlQueryExcel, self).setUp() |
|
|
|
|
|
|
|
|
super().setUp() |
|
|
self.wizard_obj = self.env['sql.file.wizard'] |
|
|
self.wizard_obj = self.env['sql.file.wizard'] |
|
|
|
|
|
|
|
|
def get_workbook_from_query(self, wizard): |
|
|
def get_workbook_from_query(self, wizard): |
|
|