From cdebafbf17bb2b1c0b51b79a13d328c9e1521e9e Mon Sep 17 00:00:00 2001 From: David Beal Date: Mon, 8 Apr 2019 17:05:08 +0200 Subject: [PATCH] PORT v12 sql_export --- sql_export/README.rst | 81 ++---------------------------- sql_export/__init__.py | 1 - sql_export/__manifest__.py | 3 +- sql_export/models/__init__.py | 2 - sql_export/models/sql_export.py | 1 - sql_export/readme/CONTRIBUTORS.rst | 9 ++++ sql_export/readme/DESCRIPTION.rst | 4 ++ sql_export/readme/ROADMAP.rst | 16 ++++++ sql_export/readme/USAGE.rst | 11 ++++ sql_export/tests/__init__.py | 2 - sql_export/tests/test_sql_query.py | 2 +- sql_export/wizard/__init__.py | 2 +- sql_export/wizard/wizard_file.py | 10 ++-- 13 files changed, 53 insertions(+), 91 deletions(-) create mode 100644 sql_export/readme/CONTRIBUTORS.rst create mode 100644 sql_export/readme/DESCRIPTION.rst create mode 100644 sql_export/readme/ROADMAP.rst create mode 100644 sql_export/readme/USAGE.rst diff --git a/sql_export/README.rst b/sql_export/README.rst index da0a9dea1..11f4118db 100644 --- a/sql_export/README.rst +++ b/sql_export/README.rst @@ -1,80 +1,9 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License: AGPL-3 - +========== SQL Export ========== -Allow to export data in csv files FROM sql requests. -There are some restrictions in the sql query, you can only read datas. -No update, deletion or creation are possible. -A new menu named Export is created. - -Known issues / Roadmap -====================== - -* Some words are prohibited and can't be used is the query in anyways, even in - a select query: - - delete - - drop - - insert - - alter - - truncate - - execute - - create - - update - -See sql_request_abstract module to fix this issue. - -* checking SQL request by execution and rollback is disabled in this module - since variables features has been introduced. This can be fixed by - overloading _prepare_request_check_execution() function. - -Usage -===== - -Dashboards > Sql Export. - -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/149/10.0 - - -Specific use with parameters ----------------------------- - -- `%(company_id)s` allows to set in the query the company id of the user -- `%(user_id)s` allows to set in the query the user id -- for any created field with `Sql Export Variables` menu, you can use it with `%(x_field_example)s` syntax - (Limitation for relational fields) - - -Bug Tracker -=========== - -Bugs are tracked on `GitHub Issues -`_. In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smash it by providing detailed and welcomed feedback. - -Credits -======= - -Contributors ------------- - -* Florian da Costa - -Maintainer ----------- - -.. image:: http://odoo-community.org/logo.png - :alt: Odoo Community Association - :target: http://odoo-community.org - -This module is maintained by the OCA. - -OCA, or the Odoo Community Association, is a nonprofit organization whose -mission is to support the collaborative development of Odoo features and -promote its widespread use. +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -To contribute to this module, please visit http://odoo-community.org. diff --git a/sql_export/__init__.py b/sql_export/__init__.py index 408a6001b..9b4296142 100644 --- a/sql_export/__init__.py +++ b/sql_export/__init__.py @@ -1,3 +1,2 @@ -# -*- coding: utf-8 -*- from . import models from . import wizard diff --git a/sql_export/__manifest__.py b/sql_export/__manifest__.py index 20eb4f992..28931db88 100644 --- a/sql_export/__manifest__.py +++ b/sql_export/__manifest__.py @@ -1,11 +1,10 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2015 Akretion () # @author: Florian da Costa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'SQL Export', - 'version': '10.0.1.0.0', + 'version': '12.0.1.0.0', 'author': 'Akretion,Odoo Community Association (OCA)', 'website': 'http://www.akretion.com', 'license': 'AGPL-3', diff --git a/sql_export/models/__init__.py b/sql_export/models/__init__.py index e7dd6865e..014462062 100644 --- a/sql_export/models/__init__.py +++ b/sql_export/models/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import sql_export diff --git a/sql_export/models/sql_export.py b/sql_export/models/sql_export.py index c1c9dc212..a685eb79b 100644 --- a/sql_export/models/sql_export.py +++ b/sql_export/models/sql_export.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright (C) 2015 Akretion () # @author: Florian da Costa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/sql_export/readme/CONTRIBUTORS.rst b/sql_export/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..3532281e0 --- /dev/null +++ b/sql_export/readme/CONTRIBUTORS.rst @@ -0,0 +1,9 @@ +* `Akretion `_: + + * Florian da Costa + * Mourad EL HADJ MIMOUNE + * BenoƮt GUILLOT + +* `Eficent `_: + + * Aaron Henriquez diff --git a/sql_export/readme/DESCRIPTION.rst b/sql_export/readme/DESCRIPTION.rst new file mode 100644 index 000000000..d739c787c --- /dev/null +++ b/sql_export/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +Allow to export data in csv files FROM sql requests. +There are some restrictions in the sql query, you can only read datas. +No update, deletion or creation are possible. +A new menu named Export is created. diff --git a/sql_export/readme/ROADMAP.rst b/sql_export/readme/ROADMAP.rst new file mode 100644 index 000000000..22dfa4c8b --- /dev/null +++ b/sql_export/readme/ROADMAP.rst @@ -0,0 +1,16 @@ +* Some words are prohibited and can't be used is the query in anyways, even in + a select query: + - delete + - drop + - insert + - alter + - truncate + - execute + - create + - update + +See sql_request_abstract module to fix this issue. + +* checking SQL request by execution and rollback is disabled in this module + since variables features has been introduced. This can be fixed by + overloading _prepare_request_check_execution() function. diff --git a/sql_export/readme/USAGE.rst b/sql_export/readme/USAGE.rst new file mode 100644 index 000000000..8f7a5b940 --- /dev/null +++ b/sql_export/readme/USAGE.rst @@ -0,0 +1,11 @@ + +Dashboards > Sql Export + + +Specific use with parameters +---------------------------- + +- `%(company_id)s` allows to set in the query the company id of the user +- `%(user_id)s` allows to set in the query the user id +- for any created field with `Sql Export Variables` menu, you can use it with `%(x_field_example)s` syntax + (Limitation for relational fields) diff --git a/sql_export/tests/__init__.py b/sql_export/tests/__init__.py index 8b2b9c21f..c483ed5a3 100644 --- a/sql_export/tests/__init__.py +++ b/sql_export/tests/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import test_sql_query diff --git a/sql_export/tests/test_sql_query.py b/sql_export/tests/test_sql_query.py index 1d7652065..631e4247d 100644 --- a/sql_export/tests/test_sql_query.py +++ b/sql_export/tests/test_sql_query.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # Copyright (C) 2015 Akretion () # @author: Florian da Costa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). diff --git a/sql_export/wizard/__init__.py b/sql_export/wizard/__init__.py index 602e1de7f..8ffbd1923 100644 --- a/sql_export/wizard/__init__.py +++ b/sql_export/wizard/__init__.py @@ -1,3 +1,3 @@ -# -*- coding: utf-8 -*- + from . import wizard_file diff --git a/sql_export/wizard/wizard_file.py b/sql_export/wizard/wizard_file.py index 0e8e038a9..95073daf5 100644 --- a/sql_export/wizard/wizard_file.py +++ b/sql_export/wizard/wizard_file.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # Copyright (C) 2015 Akretion () # @author: Florian da Costa # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -74,18 +74,18 @@ class SqlFileWizard(models.TransientModel): 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) + res = res.decode(self.sql_export_id.encoding) self.write({ 'binary_file': res, - 'file_name': sql_export.name + '_' + date + '.csv' + 'file_name': '%(name)s_%(date)s.csv' % { + 'name': sql_export.name, 'date': date} }) return { - 'view_type': 'form', 'view_mode': 'form', 'res_model': 'sql.file.wizard', 'res_id': self.id, 'type': 'ir.actions.act_window', 'target': 'new', - 'context': self._context, + 'context': self.env.context, 'nodestroy': True, }