Browse Source
[MIG] base external dbsource
[MIG] base external dbsource
* Migration of base_external_dbsource to odoo 9.0 * Fixing test error * Moving test from yaml to python * Fixing pylint error in test class * Placeholder added to connection string text zone * improving test coveragepull/550/head
Gervais Naoussi
8 years ago
committed by
Maxime Chambreuil
11 changed files with 252 additions and 147 deletions
-
82base_external_dbsource/README.rst
-
4base_external_dbsource/__init__.py
-
53base_external_dbsource/__openerp__.py
-
15base_external_dbsource/base_external_dbsource_demo.xml
-
9base_external_dbsource/demo/base_external_dbsource.xml
-
22base_external_dbsource/models/__init__.py
-
95base_external_dbsource/models/base_external_dbsource.py
-
9base_external_dbsource/test/dbsource_connect.yml
-
3base_external_dbsource/tests/__init__.py
-
58base_external_dbsource/tests/test_create_dbsource.py
-
49base_external_dbsource/views/base_external_dbsource.xml
@ -0,0 +1,82 @@ |
|||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
||||
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
||||
|
:alt: License: AGPL-3 |
||||
|
|
||||
|
========================= |
||||
|
External Database Sources |
||||
|
========================= |
||||
|
|
||||
|
This module allows you to define connections to foreign databases using ODBC, |
||||
|
Oracle Client or SQLAlchemy. |
||||
|
|
||||
|
Installation |
||||
|
============ |
||||
|
|
||||
|
No installation required. |
||||
|
|
||||
|
Configuration |
||||
|
============= |
||||
|
|
||||
|
Database sources can be configured in Settings > Configuration -> Data sources. |
||||
|
|
||||
|
Depending on the database, you need: |
||||
|
|
||||
|
* to install unixodbc and python-pyodbc packages to use ODBC connections. |
||||
|
* to install FreeTDS driver (tdsodbc package) and configure it through ODBC toconnect to Microsoft SQL Server. |
||||
|
* to install and configure Oracle Instant Client and cx_Oracle python library to connect to Oracle. |
||||
|
|
||||
|
|
||||
|
Usage |
||||
|
===== |
||||
|
|
||||
|
To use this module: |
||||
|
|
||||
|
* Go to Settings > Database Structure > Database Sources |
||||
|
* Click on Create to enter the following information: |
||||
|
|
||||
|
* Datasource name |
||||
|
* Pasword |
||||
|
* Connector: Choose the database to which you want to connect |
||||
|
* Connection string : Specify how to connect to database |
||||
|
|
||||
|
.. 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/9.0 for server-tools |
||||
|
|
||||
|
Known issues / Roadmap |
||||
|
====================== |
||||
|
|
||||
|
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 smashing it by providing a detailed and welcomed feedback `here <https://github.com/OCA/ |
||||
|
server-tools/issues/new?body=module:%20 |
||||
|
base_external_dbsource%0Aversion:%20 |
||||
|
9.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
||||
|
|
||||
|
Credits |
||||
|
======= |
||||
|
|
||||
|
Contributors |
||||
|
------------ |
||||
|
|
||||
|
* Daniel Reis <dreis.pt@hotmail.com> |
||||
|
* Maxime Chambreuil <maxime.chambreuil@savoirfairelinux.com> |
||||
|
* Gervais Naoussi <gervaisnaoussi@gmail.com> |
||||
|
|
||||
|
Maintainer |
||||
|
---------- |
||||
|
|
||||
|
.. image:: https://odoo-community.org/logo.png |
||||
|
:alt: Odoo Community Association |
||||
|
:target: https://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. |
||||
|
|
||||
|
To contribute to this module, please visit http://odoo-community.org. |
@ -1,15 +0,0 @@ |
|||||
<?xml version="1.0"?> |
|
||||
<openerp> |
|
||||
<data> |
|
||||
|
|
||||
<record model="base.external.dbsource" id="demo_postgre"> |
|
||||
<field name="name">PostgreSQL local</field> |
|
||||
<field name="conn_string">dbname='postgres' password=%s</field> |
|
||||
<field name="password">postgresql</field> |
|
||||
<field name="connector">postgresql</field> |
|
||||
</record> |
|
||||
|
|
||||
</data> |
|
||||
</openerp> |
|
||||
|
|
||||
|
|
@ -0,0 +1,9 @@ |
|||||
|
<?xml version="1.0"?> |
||||
|
<odoo> |
||||
|
<record model="base.external.dbsource" id="demo_postgre"> |
||||
|
<field name="name">PostgreSQL local</field> |
||||
|
<field name="conn_string">dbname='postgres' password=%s</field> |
||||
|
<field name="password">postgresql</field> |
||||
|
<field name="connector">postgresql</field> |
||||
|
</record> |
||||
|
</odoo> |
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
############################################################################## |
||||
|
# |
||||
|
# Daniel Reis |
||||
|
# 2011 |
||||
|
# |
||||
|
# 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 . import base_external_dbsource |
@ -1,9 +0,0 @@ |
|||||
- |
|
||||
Connect to local Postgres. |
|
||||
- |
|
||||
!python {model: base.external.dbsource}: | |
|
||||
from openerp.osv.orm import except_orm |
|
||||
try: |
|
||||
self.connection_test(cr, uid, [ref("demo_postgre")]) |
|
||||
except except_orm as e: |
|
||||
assert e.value == u'Everything seems properly set up!' |
|
@ -0,0 +1,3 @@ |
|||||
|
# -*- encoding: utf-8 -*- |
||||
|
|
||||
|
from . import test_create_dbsource |
@ -0,0 +1,58 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
from openerp.exceptions import Warning as UserError |
||||
|
from openerp.tests import common |
||||
|
import logging |
||||
|
|
||||
|
|
||||
|
class TestCreateDbsource(common.TransactionCase): |
||||
|
"""Test class for base_external_dbsource.""" |
||||
|
|
||||
|
def test_create_dbsource(self): |
||||
|
"""source creation should succeed.""" |
||||
|
dbsource = self.env.ref('base_external_dbsource.demo_postgre') |
||||
|
try: |
||||
|
dbsource.connection_test() |
||||
|
except UserError as e: |
||||
|
logging.warning("Log = " + str(e)) |
||||
|
self.assertTrue(u'Everything seems properly set up!' in str(e)) |
||||
|
|
||||
|
def test_create_dbsource_failed(self): |
||||
|
"""source creation without connection string should failed.""" |
||||
|
dbsource = self.env.ref('base_external_dbsource.demo_postgre') |
||||
|
|
||||
|
# Connection without connection_string |
||||
|
dbsource.conn_string = "" |
||||
|
try: |
||||
|
dbsource.connection_test() |
||||
|
except UserError as e: |
||||
|
logging.warning("Log = " + str(e)) |
||||
|
self.assertTrue(u'Here is what we got instead:' in str(e)) |
||||
|
|
||||
|
def test_create_dbsource_without_connector_failed(self): |
||||
|
"""source creation with other connector should failed.""" |
||||
|
dbsource = self.env.ref('base_external_dbsource.demo_postgre') |
||||
|
|
||||
|
# Connection to mysql |
||||
|
try: |
||||
|
dbsource.connector = "mysql" |
||||
|
dbsource.connection_test() |
||||
|
except ValueError as e: |
||||
|
logging.warning("Log = " + str(e)) |
||||
|
self.assertTrue(u'Wrong value for' in str(e)) |
||||
|
|
||||
|
# Connection to mysql |
||||
|
try: |
||||
|
dbsource.connector = "pyodbc" |
||||
|
dbsource.connection_test() |
||||
|
except ValueError as e: |
||||
|
logging.warning("Log = " + str(e)) |
||||
|
self.assertTrue(u'Wrong value for' in str(e)) |
||||
|
|
||||
|
# Connection to oracle |
||||
|
try: |
||||
|
dbsource.connector = "cx_Oracle" |
||||
|
dbsource.connection_test() |
||||
|
except ValueError as e: |
||||
|
logging.warning("Log = " + str(e)) |
||||
|
self.assertTrue(u'Wrong value for' in str(e)) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue