diff --git a/base_external_dbsource_mssql/README.rst b/base_external_dbsource_mssql/README.rst new file mode 100644 index 000000000..b9511f457 --- /dev/null +++ b/base_external_dbsource_mssql/README.rst @@ -0,0 +1,139 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +================================ +External Database Source - MSSQL +================================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:2ba068b9b5070aba3418c4fda6a9db61fd15dcda32f038d2aa04ffba29951845 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github + :target: https://github.com/OCA/server-backend/tree/19.0/base_external_dbsource_mssql + :alt: OCA/server-backend +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-backend-19-0/server-backend-19-0-base_external_dbsource_mssql + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-backend&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends ``base_external_dbsource``, allowing you to connect +to foreign MSSQL databases using SQLAlchemy. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +To install this module, you need to: + +- Install & configure FreeTDS driver (tdsodbc package) +- Install ``sqlalchemy`` & ``pymssql`` python libraries +- Install ``base_external_dbsource`` Odoo module + +Configuration +============= + +To configure this module, you need to: + +1. Database sources can be configured in Settings > Technical > Database + Structure > Database sources. + +Usage +===== + +To use this module: + +- Go to Settings > Technical > 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 + +Known issues / Roadmap +====================== + +- Add X.509 authentication + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Daniel Reis +* LasLabs + +Contributors +------------ + +- Daniel Reis + +- Maxime Chambreuil + +- Gervais Naoussi + +- Dave Lasley + +- + + - `Tecnativa `__: + + - Sergio Teruel + - Carolina Fernandez + +- Andrea Cattalani (`Moduon `__) + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +.. |maintainer-anddago78| image:: https://github.com/anddago78.png?size=40px + :target: https://github.com/anddago78 + :alt: anddago78 + +Current `maintainer `__: + +|maintainer-anddago78| + +This module is part of the `OCA/server-backend `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_external_dbsource_mssql/__init__.py b/base_external_dbsource_mssql/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/base_external_dbsource_mssql/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/base_external_dbsource_mssql/__manifest__.py b/base_external_dbsource_mssql/__manifest__.py new file mode 100644 index 000000000..7621dae57 --- /dev/null +++ b/base_external_dbsource_mssql/__manifest__.py @@ -0,0 +1,22 @@ +# Copyright <2011> +# Copyright 2016 LasLabs Inc. +# Copyright 2024 Tecnativa - Carolina Fernandez +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). +{ + "name": "External Database Source - MSSQL", + "version": "19.0.1.0.0", + "category": "Tools", + "author": "Daniel Reis, LasLabs, Odoo Community Association (OCA)", + "maintainers": ["anddago78"], + "website": "https://github.com/OCA/server-backend", + "license": "LGPL-3", + "depends": ["base_external_dbsource"], + "external_dependencies": { + "python": [ + "pymssql", + "sqlalchemy", + ] + }, + "demo": ["demo/base_external_dbsource.xml"], + "installable": True, +} diff --git a/base_external_dbsource_mssql/demo/base_external_dbsource.xml b/base_external_dbsource_mssql/demo/base_external_dbsource.xml new file mode 100644 index 000000000..d1068d009 --- /dev/null +++ b/base_external_dbsource_mssql/demo/base_external_dbsource.xml @@ -0,0 +1,11 @@ + + + + MSSQL Demo + mssql+pymssql://myUsername:%s@myServerAddress:port/myDataBase + password + mssql + + diff --git a/base_external_dbsource_mssql/i18n/base_external_dbsource_mssql.pot b/base_external_dbsource_mssql/i18n/base_external_dbsource_mssql.pot new file mode 100644 index 000000000..84ef40820 --- /dev/null +++ b/base_external_dbsource_mssql/i18n/base_external_dbsource_mssql.pot @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_mssql +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,field_description:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model,name:base_external_dbsource_mssql.model_base_external_dbsource +msgid "External Database Sources" +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,help:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields.selection,name:base_external_dbsource_mssql.selection__base_external_dbsource__connector__mssql +msgid "Microsoft SQL Server" +msgstr "" diff --git a/base_external_dbsource_mssql/i18n/de.po b/base_external_dbsource_mssql/i18n/de.po new file mode 100644 index 000000000..8f5f1a6e2 --- /dev/null +++ b/base_external_dbsource_mssql/i18n/de.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_mssql +# +# Translators: +# Rudolf Schnapka , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-10 00:47+0000\n" +"PO-Revision-Date: 2017-05-10 00:47+0000\n" +"Last-Translator: Rudolf Schnapka , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,field_description:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model,name:base_external_dbsource_mssql.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Externe Datenbankquellen" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,help:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields.selection,name:base_external_dbsource_mssql.selection__base_external_dbsource__connector__mssql +msgid "Microsoft SQL Server" +msgstr "" diff --git a/base_external_dbsource_mssql/i18n/es.po b/base_external_dbsource_mssql/i18n/es.po new file mode 100644 index 000000000..34b114ebf --- /dev/null +++ b/base_external_dbsource_mssql/i18n/es.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_mssql +# +# Translators: +# Fernando Lara , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-22 00:54+0000\n" +"PO-Revision-Date: 2023-08-28 09:10+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,field_description:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "Connector" +msgstr "Conector" + +#. module: base_external_dbsource_mssql +#: model:ir.model,name:base_external_dbsource_mssql.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Fuentes externas de la base de datos" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,help:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" +"Si falta un conector en la lista, compruebe el registro del servidor para " +"confirmar que se han detectado los componentes necesarios." + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields.selection,name:base_external_dbsource_mssql.selection__base_external_dbsource__connector__mssql +msgid "Microsoft SQL Server" +msgstr "Servidor SQL de Microsoft" diff --git a/base_external_dbsource_mssql/i18n/hr.po b/base_external_dbsource_mssql/i18n/hr.po new file mode 100644 index 000000000..1be4c8c83 --- /dev/null +++ b/base_external_dbsource_mssql/i18n/hr.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_mssql +# +# Translators: +# Bole , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-10 00:47+0000\n" +"PO-Revision-Date: 2017-05-10 00:47+0000\n" +"Last-Translator: Bole , 2017\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,field_description:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model,name:base_external_dbsource_mssql.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Vanjske baze" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,help:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields.selection,name:base_external_dbsource_mssql.selection__base_external_dbsource__connector__mssql +msgid "Microsoft SQL Server" +msgstr "" diff --git a/base_external_dbsource_mssql/i18n/it.po b/base_external_dbsource_mssql/i18n/it.po new file mode 100644 index 000000000..6b5eaeca9 --- /dev/null +++ b/base_external_dbsource_mssql/i18n/it.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_mssql +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-05 11:35+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,field_description:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "Connector" +msgstr "Connettore" + +#. module: base_external_dbsource_mssql +#: model:ir.model,name:base_external_dbsource_mssql.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Origini database esterne" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,help:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" +"Se il connettore è mancante dalla lista, controllare il log del server per " +"avere conferma che i componenti richiesti siano stati rilevati." + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields.selection,name:base_external_dbsource_mssql.selection__base_external_dbsource__connector__mssql +msgid "Microsoft SQL Server" +msgstr "Microsoft SQL Server" diff --git a/base_external_dbsource_mssql/i18n/nl_NL.po b/base_external_dbsource_mssql/i18n/nl_NL.po new file mode 100644 index 000000000..c2b650a2e --- /dev/null +++ b/base_external_dbsource_mssql/i18n/nl_NL.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_mssql +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-22 01:11+0000\n" +"PO-Revision-Date: 2017-06-22 01:11+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,field_description:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model,name:base_external_dbsource_mssql.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Externe databasebronnen" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,help:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields.selection,name:base_external_dbsource_mssql.selection__base_external_dbsource__connector__mssql +msgid "Microsoft SQL Server" +msgstr "" diff --git a/base_external_dbsource_mssql/i18n/pt_BR.po b/base_external_dbsource_mssql/i18n/pt_BR.po new file mode 100644 index 000000000..21809cd1f --- /dev/null +++ b/base_external_dbsource_mssql/i18n/pt_BR.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_mssql +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-21 04:22+0000\n" +"PO-Revision-Date: 2024-05-22 15:40+0000\n" +"Last-Translator: Rodrigo Macedo \n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/" +"23907/pt_BR/)\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,field_description:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "Connector" +msgstr "Conector" + +#. module: base_external_dbsource_mssql +#: model:ir.model,name:base_external_dbsource_mssql.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Fontes Banco de Dados Externo" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,help:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" +"Se um conector estiver ausente na lista, verifique o log do servidor para " +"confirmar se os componentes necessários foram detectados." + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields.selection,name:base_external_dbsource_mssql.selection__base_external_dbsource__connector__mssql +msgid "Microsoft SQL Server" +msgstr "Servidor Microsoft SQL" diff --git a/base_external_dbsource_mssql/i18n/sl.po b/base_external_dbsource_mssql/i18n/sl.po new file mode 100644 index 000000000..458e14be4 --- /dev/null +++ b/base_external_dbsource_mssql/i18n/sl.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_mssql +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-21 04:22+0000\n" +"PO-Revision-Date: 2017-01-21 04:22+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,field_description:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model,name:base_external_dbsource_mssql.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Viri zunanjih podatkovnih baz" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,help:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields.selection,name:base_external_dbsource_mssql.selection__base_external_dbsource__connector__mssql +msgid "Microsoft SQL Server" +msgstr "" diff --git a/base_external_dbsource_mssql/i18n/tr.po b/base_external_dbsource_mssql/i18n/tr.po new file mode 100644 index 000000000..de8870cba --- /dev/null +++ b/base_external_dbsource_mssql/i18n/tr.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_mssql +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-21 04:22+0000\n" +"PO-Revision-Date: 2017-01-21 04:22+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" +"Language: tr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,field_description:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model,name:base_external_dbsource_mssql.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Dış veritabanı kaynakları" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields,help:base_external_dbsource_mssql.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_mssql +#: model:ir.model.fields.selection,name:base_external_dbsource_mssql.selection__base_external_dbsource__connector__mssql +msgid "Microsoft SQL Server" +msgstr "" diff --git a/base_external_dbsource_mssql/models/__init__.py b/base_external_dbsource_mssql/models/__init__.py new file mode 100644 index 000000000..91032fcb6 --- /dev/null +++ b/base_external_dbsource_mssql/models/__init__.py @@ -0,0 +1 @@ +from . import base_external_dbsource diff --git a/base_external_dbsource_mssql/models/base_external_dbsource.py b/base_external_dbsource_mssql/models/base_external_dbsource.py new file mode 100644 index 000000000..2985f9c0b --- /dev/null +++ b/base_external_dbsource_mssql/models/base_external_dbsource.py @@ -0,0 +1,48 @@ +# Copyright 2011 Daniel Reis +# Copyright 2016 LasLabs Inc. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). +# this is needed to generate connection string +import pymssql +import sqlalchemy + +from odoo import fields, models + +assert pymssql + + +class BaseExternalDbsource(models.Model): + """It provides logic for connection to a MSSQL data source.""" + + _inherit = "base.external.dbsource" + + connector = fields.Selection( + selection_add=[("mssql", "Microsoft SQL Server")], ondelete={"mssql": "cascade"} + ) + PWD_STRING_MSSQL = "Password=%s;" + + def connection_close_mssql(self, connection): + return connection.close() + + def connection_open_mssql(self): + return self._connection_open_mssql() + + def execute_mssql(self, sqlquery, sqlparams, metadata): + return self._execute_mssql(sqlquery, sqlparams, metadata) + + def _connection_open_mssql(self): + return sqlalchemy.create_engine(self.conn_string_full).connect() + + def _execute_mssql(self, sqlquery, sqlparams, metadata): + rows, cols = list(), list() + for record in self: + with record.connection_open() as connection: + if sqlparams is None: + cur = connection.execute(sqlquery) + else: + cur = connection.execute(sqlquery, sqlparams) + if metadata: + cols = list(cur.keys()) + # If the query doesn't return rows, trying to get them anyway + # will raise an exception `sqlalchemy.exc.ResourceClosedError` + rows = [r for r in cur] if cur.returns_rows else [] + return rows, cols diff --git a/base_external_dbsource_mssql/pyproject.toml b/base_external_dbsource_mssql/pyproject.toml new file mode 100644 index 000000000..4231d0ccc --- /dev/null +++ b/base_external_dbsource_mssql/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/base_external_dbsource_mssql/readme/CONFIGURE.md b/base_external_dbsource_mssql/readme/CONFIGURE.md new file mode 100644 index 000000000..9a93e6daf --- /dev/null +++ b/base_external_dbsource_mssql/readme/CONFIGURE.md @@ -0,0 +1,4 @@ +To configure this module, you need to: + +1. Database sources can be configured in Settings \> Technical \> + Database Structure \> Database sources. diff --git a/base_external_dbsource_mssql/readme/CONTRIBUTORS.md b/base_external_dbsource_mssql/readme/CONTRIBUTORS.md new file mode 100644 index 000000000..d3244e747 --- /dev/null +++ b/base_external_dbsource_mssql/readme/CONTRIBUTORS.md @@ -0,0 +1,14 @@ + - Daniel Reis \<\> + + - Maxime Chambreuil \<\> + + - Gervais Naoussi \<\> + + - Dave Lasley \<\> + + - - [Tecnativa](https://www.tecnativa.com): + + - Sergio Teruel + - Carolina Fernandez + + - Andrea Cattalani ([Moduon](https://www.moduon.team/)) diff --git a/base_external_dbsource_mssql/readme/DESCRIPTION.md b/base_external_dbsource_mssql/readme/DESCRIPTION.md new file mode 100644 index 000000000..a40a5915c --- /dev/null +++ b/base_external_dbsource_mssql/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends `base_external_dbsource`, allowing you to connect to +foreign MSSQL databases using SQLAlchemy. diff --git a/base_external_dbsource_mssql/readme/INSTALL.md b/base_external_dbsource_mssql/readme/INSTALL.md new file mode 100644 index 000000000..91c8f9320 --- /dev/null +++ b/base_external_dbsource_mssql/readme/INSTALL.md @@ -0,0 +1,5 @@ +To install this module, you need to: + + - Install & configure FreeTDS driver (tdsodbc package) + - Install `sqlalchemy` & `pymssql` python libraries + - Install `base_external_dbsource` Odoo module diff --git a/base_external_dbsource_mssql/readme/ROADMAP.md b/base_external_dbsource_mssql/readme/ROADMAP.md new file mode 100644 index 000000000..e913ab8c1 --- /dev/null +++ b/base_external_dbsource_mssql/readme/ROADMAP.md @@ -0,0 +1 @@ + - Add X.509 authentication diff --git a/base_external_dbsource_mssql/readme/USAGE.md b/base_external_dbsource_mssql/readme/USAGE.md new file mode 100644 index 000000000..badf70f60 --- /dev/null +++ b/base_external_dbsource_mssql/readme/USAGE.md @@ -0,0 +1,9 @@ +To use this module: + + - Go to Settings \> Technical \> 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 diff --git a/base_external_dbsource_mssql/static/description/icon.png b/base_external_dbsource_mssql/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/base_external_dbsource_mssql/static/description/icon.png differ diff --git a/base_external_dbsource_mssql/static/description/index.html b/base_external_dbsource_mssql/static/description/index.html new file mode 100644 index 000000000..83117cf2b --- /dev/null +++ b/base_external_dbsource_mssql/static/description/index.html @@ -0,0 +1,484 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

External Database Source - MSSQL

+ +

Beta License: LGPL-3 OCA/server-backend Translate me on Weblate Try me on Runboat

+

This module extends base_external_dbsource, allowing you to connect +to foreign MSSQL databases using SQLAlchemy.

+

Table of contents

+ +
+

Installation

+

To install this module, you need to:

+
    +
  • Install & configure FreeTDS driver (tdsodbc package)
  • +
  • Install sqlalchemy & pymssql python libraries
  • +
  • Install base_external_dbsource Odoo module
  • +
+
+
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Database sources can be configured in Settings > Technical > Database +Structure > Database sources.
  2. +
+
+
+

Usage

+

To use this module:

+
    +
  • Go to Settings > Technical > 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
  • +
+
+
+

Known issues / Roadmap

+
    +
  • Add X.509 authentication
  • +
+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Daniel Reis
  • +
  • LasLabs
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

Current maintainer:

+

anddago78

+

This module is part of the OCA/server-backend project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/base_external_dbsource_mssql/tests/__init__.py b/base_external_dbsource_mssql/tests/__init__.py new file mode 100644 index 000000000..87aa84b3e --- /dev/null +++ b/base_external_dbsource_mssql/tests/__init__.py @@ -0,0 +1 @@ +from . import test_base_external_dbsource diff --git a/base_external_dbsource_mssql/tests/test_base_external_dbsource.py b/base_external_dbsource_mssql/tests/test_base_external_dbsource.py new file mode 100644 index 000000000..9477480ed --- /dev/null +++ b/base_external_dbsource_mssql/tests/test_base_external_dbsource.py @@ -0,0 +1,37 @@ +# Copyright 2016 LasLabs Inc. +# Copyright 2024 Tecnativa - Carolina Fernandez +from unittest import mock + +from odoo.tests import common + +ADAPTER = ( + "odoo.addons.base_external_dbsource_mssql.models.base_external_dbsource.pymssql" +) + + +class TestBaseExternalDbsource(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.dbsource = cls.env.ref("base_external_dbsource_mssql.demo_mssql") + + def test_connection_close_mssql(self): + """It should close the connection""" + connection = mock.MagicMock() + res = self.dbsource.connection_close_mssql(connection) + self.assertEqual(res, connection.close()) + + def test_connection_open_mssql(self): + """It should call SQLAlchemy open""" + with mock.patch.object( + type(self.dbsource), "_connection_open_mssql" + ) as parent_method: + self.dbsource.connection_open_mssql() + parent_method.assert_called_once_with() + + def test_excecute_mssql(self): + """It should pass args to SQLAlchemy execute""" + expect = "sqlquery", "sqlparams", "metadata" + with mock.patch.object(type(self.dbsource), "_execute_mssql") as parent_method: + self.dbsource.execute_mssql(*expect) + parent_method.assert_called_once_with(*expect) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..d5544d6f4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +# generated from manifests external_dependencies +pymssql +sqlalchemy diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 000000000..d50db702d --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1 @@ +odoo-addon-base_external_dbsource @ git+https://github.com/OCA/server-backend.git@refs/pull/415/head#subdirectory=base_external_dbsource