Browse Source

Merge pull request #18 from aheficent/9.0-sql_report

[IMP]encode output file
pull/535/head
Sylvain LE GAL 8 years ago
committed by GitHub
parent
commit
84896db3f5
  1. 0
      9.0-sql_report
  2. 8
      sql_export/models/sql_export.py
  3. 1
      sql_export/views/sql_export_view.xml
  4. 3
      sql_export/wizard/wizard_file.py

0
9.0-sql_report

8
sql_export/models/sql_export.py

@ -45,6 +45,14 @@ class SqlExport(models.Model):
'Parameters',
domain=[('model', '=', 'sql.file.wizard')])
encoding = fields.Selection(
[('utf-8', 'utf-8'), ('utf-16', 'utf-16'),
('windows-1252', 'windows-1252'), ('latin1', 'latin1'),
('latin2', 'latin2'), ('big5', 'big5'), ('gb18030', 'gb18030'),
('shift_jis', 'shift_jis'), ('windows-1251', 'windows-1251'),
('koir8_r', 'koir8_r')], string='Encoding', required=True,
default='utf-8')
@api.multi
def export_sql_query(self):
self.ensure_one()

1
sql_export/views/sql_export_view.xml

@ -25,6 +25,7 @@
</group>
<group name="option" groups="sql_request_abstract.group_sql_request_user">
<field name="copy_options"/>
<field name="encoding"/>
</group>
<group name="request" string="SQL Request" groups="sql_request_abstract.group_sql_request_user">
<field name="query" nolabel="1" placeholder="select * from res_partner"/>

3
sql_export/wizard/wizard_file.py

@ -89,7 +89,8 @@ class SqlFileWizard(models.TransientModel):
res = sql_export._execute_sql_request(
params=variable_dict, mode='stdout',
copy_options=sql_export.copy_options)
if self.sql_export_id.encoding:
res = res.encode(self.sql_export_id.encoding)
self.write({
'binary_file': res,
'file_name': sql_export.name + '_' + date + '.csv'

Loading…
Cancel
Save