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
parent
commit
68448cfa74
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      sql_export/models/sql_export.py
  2. 6
      sql_export/wizard/wizard_file.py
  3. 6
      sql_export_excel/models/sql_export.py
  4. 2
      sql_export_excel/tests/test_sql_query_excel.py

2
sql_export/models/sql_export.py

@ -59,7 +59,7 @@ class SqlExport(models.Model):
if self.file_format == 'csv':
return 'csv'
def csv_get_datas_from_query(self, variable_dict):
def csv_get_data_from_query(self, variable_dict):
self.ensure_one()
# Execute Request
res = self._execute_sql_request(

6
sql_export/wizard/wizard_file.py

@ -70,11 +70,11 @@ class SqlFileWizard(models.TransientModel):
# Call different method depending on file_type since the logic will be
# 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()
self.write({
'binary_file': datas,
'binary_file': data,
'file_name': '%(name)s_%(date)s.%(extension)s' % {
'name': sql_export.name, 'date': date, 'extension': extension}
})

6
sql_export_excel/models/sql_export.py

@ -1,7 +1,7 @@
# Copyright 2019 Akretion
# 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
import logging
import base64
@ -67,10 +67,10 @@ class SqlExport(models.Model):
if self.file_format == 'excel':
return 'xlsx'
else:
return super(SqlExport, self)._get_file_extension()
return super()._get_file_extension()
@api.multi
def excel_get_datas_from_query(self, variable_dict):
def excel_get_data_from_query(self, variable_dict):
self.ensure_one()
res = self._execute_sql_request(
params=variable_dict, mode='fetchall', header=self.header)

2
sql_export_excel/tests/test_sql_query_excel.py

@ -18,7 +18,7 @@ except ImportError:
class TestExportSqlQueryExcel(TransactionCase):
def setUp(self):
super(TestExportSqlQueryExcel, self).setUp()
super().setUp()
self.wizard_obj = self.env['sql.file.wizard']
def get_workbook_from_query(self, wizard):

Loading…
Cancel
Save