[MIG][10.0]sql_export v10
parent
a18b98187b
commit
2f8ae9a7a6
|
@ -5,14 +5,15 @@ SQL Export
|
|||
==========
|
||||
|
||||
Allow to export data in csv files FROM sql requests.
|
||||
There are some restrictions in the sql sql request, you can only read datas.
|
||||
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 prohibeted and can't be used is the query in anyways, even in a select query :
|
||||
* Some words are prohibeted and can't be used is the query in anyways, even in
|
||||
a select query :
|
||||
* delete
|
||||
* drop
|
||||
* insert
|
||||
|
@ -28,6 +29,14 @@ See sql_request_abstract module to fix this issue.
|
|||
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
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from . import models
|
||||
from . import wizard
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
# -*- 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',
|
||||
'author': 'Akretion,Odoo Community Association (OCA)',
|
||||
'website': 'http://www.akretion.com',
|
||||
'license': 'AGPL-3',
|
||||
'category': 'Generic Modules/Others',
|
||||
'summary': 'Export data in csv file with SQL requests',
|
||||
'depends': [
|
||||
'sql_request_abstract',
|
||||
],
|
||||
'data': [
|
||||
'views/sql_export_view.xml',
|
||||
'wizard/wizard_file_view.xml',
|
||||
'security/sql_export_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'demo': [
|
||||
'demo/sql_export.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2015 Akretion (<http://www.akretion.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
'name': 'SQL Export',
|
||||
'version': '9.0.1.0.0',
|
||||
'author': 'Akretion,Odoo Community Association (OCA)',
|
||||
'website': 'http://www.akretion.com',
|
||||
'license': 'AGPL-3',
|
||||
'category': 'Generic Modules/Others',
|
||||
'summary': 'Export data in csv file with SQL requests',
|
||||
'depends': [
|
||||
'sql_request_abstract',
|
||||
],
|
||||
'data': [
|
||||
'views/sql_export_view.xml',
|
||||
'wizard/wizard_file_view.xml',
|
||||
'security/sql_export_security.xml',
|
||||
'security/ir.model.access.csv',
|
||||
],
|
||||
'demo': [
|
||||
'demo/sql_export.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
|
@ -5,7 +5,7 @@ Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
|
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
-->
|
||||
|
||||
<openerp><data>
|
||||
<odoo>
|
||||
|
||||
<record id="sql_export_partner" model="sql.export">
|
||||
<field name="name">Export Partners (Demo Data)</field>
|
||||
|
@ -14,4 +14,4 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|||
|
||||
<function model="sql.export" name="button_validate_sql_expression" eval="([ref('sql_export.sql_export_partner')])"/>
|
||||
|
||||
</data></openerp>
|
||||
</odoo>
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import sql_export
|
||||
|
|
|
@ -1,25 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2015 Akretion (<http://www.akretion.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from openerp import models, fields, api
|
||||
# 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).
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class SqlExport(models.Model):
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data noupdate="0">
|
||||
<odoo noupdate="1">
|
||||
|
||||
<record model="ir.rule" id="sql_export_restric_access_user_or_group">
|
||||
<field name="name" >SQL Export users and groups rules</field>
|
||||
|
@ -12,5 +11,4 @@
|
|||
<field name="domain_force">['|', ('user_ids','=',user.id), ('group_ids','in', [x.id for x in user.groups_id])]</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_sql_query
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
import base64
|
||||
from openerp.tests.common import TransactionCase
|
||||
from openerp.exceptions import Warning as UserError
|
||||
from odoo.tests.common import TransactionCase
|
||||
from odoo.exceptions import Warning as UserError
|
||||
|
||||
|
||||
class TestExportSqlQuery(TransactionCase):
|
||||
|
|
|
@ -1,47 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
|
||||
<odoo>
|
||||
<record id="sql_export_view_form" model="ir.ui.view">
|
||||
<field name="name">Sql_export_form_view</field>
|
||||
<field name="model">sql.export</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="SQL export">
|
||||
<header>
|
||||
<button name="button_validate_sql_expression" type="object" states="draft"
|
||||
string="Validate SQL Expression" class="oe_highlight"/>
|
||||
<button name="button_set_draft" type="object" states="sql_valid"
|
||||
string="Set to Draft" groups="sql_request_abstract.group_sql_request_manager"/>
|
||||
<button name="export_sql_query" string="Execute Query" states="sql_valid" type="object" class="oe_highlight"
|
||||
icon="fa-arrow-right text-success"/>
|
||||
<field name="state" widget="statusbar"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<header>
|
||||
<button name="button_validate_sql_expression" type="object" states="draft"
|
||||
string="Validate SQL Expression" class="oe_highlight"/>
|
||||
<button name="button_set_draft" type="object" states="sql_valid"
|
||||
string="Set to Draft" groups="sql_request_abstract.group_sql_request_manager"/>
|
||||
<button name="export_sql_query" string="Execute Query" states="sql_valid" type="object" class="oe_highlight"
|
||||
icon="gtk-execute"/>
|
||||
<field name="state" widget="statusbar" />
|
||||
</header>
|
||||
<group>
|
||||
<h1>
|
||||
<field name="name" nolabel="1" placeholder="Request Name"/>
|
||||
</h1>
|
||||
</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"/>
|
||||
</group>
|
||||
<group string="Parameters" groups="sql_request_abstract.group_sql_request_user">
|
||||
<field name="field_ids" nolabel="1"/>
|
||||
</group>
|
||||
<group groups="sql_request_abstract.group_sql_request_manager">
|
||||
<group string="Allowed Users">
|
||||
<field name="user_ids" nolabel="1"/>
|
||||
<group>
|
||||
<h1>
|
||||
<field name="name" nolabel="1" placeholder="Request Name"/>
|
||||
</h1>
|
||||
</group>
|
||||
<group string="Allowed Groups">
|
||||
<field name="group_ids" nolabel="1"/>
|
||||
<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"/>
|
||||
</group>
|
||||
<group name="parameters" string="Parameters" groups="sql_request_abstract.group_sql_request_user">
|
||||
<field name="field_ids" nolabel="1"/>
|
||||
</group>
|
||||
<group groups="sql_request_abstract.group_sql_request_manager">
|
||||
<group string="Allowed Users" name="users_allowed">
|
||||
<field name="user_ids" nolabel="1"/>
|
||||
</group>
|
||||
<group string="Allowed Groups" name="groups_allowed">
|
||||
<field name="group_ids" nolabel="1"/>
|
||||
</group>
|
||||
|
||||
</group>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
|
@ -55,7 +52,7 @@
|
|||
<field name="name"/>
|
||||
<field name="state"/>
|
||||
<button name="export_sql_query" string="Execute Query" states="sql_valid" type="object"
|
||||
icon="gtk-execute"/>
|
||||
icon="fa-arrow-right text-success"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -103,6 +100,4 @@
|
|||
|
||||
<menuitem id="sql_parameter_menu_view" name="Sql Export Variables" parent="sql_export_menu" action="sql_parameter_tree_action" sequence="5" groups="sql_request_abstract.group_sql_request_manager"/>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import wizard_file
|
||||
|
|
|
@ -1,29 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2015 Akretion (<http://www.akretion.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
# 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).
|
||||
|
||||
import datetime
|
||||
from lxml import etree
|
||||
|
||||
from openerp import models, fields, api, osv
|
||||
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
||||
from odoo import models, fields, api, osv
|
||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
||||
|
||||
|
||||
class SqlFileWizard(models.TransientModel):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<record id="sql_file_wizard_view_form" model="ir.ui.view">
|
||||
|
@ -14,14 +14,14 @@
|
|||
<field name="file_name" invisible="1"/>
|
||||
<footer>
|
||||
<button name="export_sql" string="Export" type="object"
|
||||
icon="gtk-apply" />
|
||||
icon="fa-download"/>
|
||||
or
|
||||
<button special="cancel" string="Cancel" type="object"
|
||||
icon="gtk-cancel" />
|
||||
icon="fa-times" />
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
|
|
Loading…
Reference in New Issue