Browse Source

PORT v12 sql_export

pull/1554/head
David Beal 6 years ago
parent
commit
cdebafbf17
  1. 81
      sql_export/README.rst
  2. 1
      sql_export/__init__.py
  3. 3
      sql_export/__manifest__.py
  4. 2
      sql_export/models/__init__.py
  5. 1
      sql_export/models/sql_export.py
  6. 9
      sql_export/readme/CONTRIBUTORS.rst
  7. 4
      sql_export/readme/DESCRIPTION.rst
  8. 16
      sql_export/readme/ROADMAP.rst
  9. 11
      sql_export/readme/USAGE.rst
  10. 2
      sql_export/tests/__init__.py
  11. 2
      sql_export/tests/test_sql_query.py
  12. 2
      sql_export/wizard/__init__.py
  13. 10
      sql_export/wizard/wizard_file.py

81
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
<https://github.com/OCA/server-tools/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 <florian.dacosta@akretion.com>
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.

1
sql_export/__init__.py

@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-
from . import models
from . import wizard

3
sql_export/__manifest__.py

@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2015 Akretion (<http://www.akretion.com>)
# @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',

2
sql_export/models/__init__.py

@ -1,3 +1 @@
# -*- coding: utf-8 -*-
from . import sql_export

1
sql_export/models/sql_export.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2015 Akretion (<http://www.akretion.com>)
# @author: Florian da Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

9
sql_export/readme/CONTRIBUTORS.rst

@ -0,0 +1,9 @@
* `Akretion <https://www.akretion.com>`_:
* Florian da Costa <florian.dacosta@akretion.com>
* Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
* Benoît GUILLOT <benoit.guillot@akretion.com>
* `Eficent <https://www.eficent.com>`_:
* Aaron Henriquez <ahenriquez@eficent.com>

4
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.

16
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.

11
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)

2
sql_export/tests/__init__.py

@ -1,3 +1 @@
# -*- coding: utf-8 -*-
from . import test_sql_query

2
sql_export/tests/test_sql_query.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2015 Akretion (<http://www.akretion.com>)
# @author: Florian da Costa
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

2
sql_export/wizard/__init__.py

@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
from . import wizard_file

10
sql_export/wizard/wizard_file.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2015 Akretion (<http://www.akretion.com>)
# @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,
}
Loading…
Cancel
Save