Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Install system dependencies
run: apt update && apt install -y --no-install-recommends libodbc2 unixodbc-dev
- name: Install addons and dependencies
run: oca_install_addons
- name: Check licenses
Expand Down
125 changes: 125 additions & 0 deletions base_external_dbsource_mssql_by_odbc/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
========================================
External Database Source - MSSQL By ODBC
========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:772c59dda6323419b6cdceea44248da043f86e91201bee74c7300004550b7012
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/licence-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/18.0/base_external_dbsource_mssql_by_odbc
: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-18-0/server-backend-18-0-base_external_dbsource_mssql_by_odbc
: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=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends ``base_external_dbsource_mssql``, allowing you to
connect to foreign MSSQL databases using PyODBC.

**Table of contents**

.. contents::
:local:

Installation
============

To install this module, you need to:

- Install & configure FreeTDS driver (tdsodbc package)
- Install ``pyodbc`` python libraries
- Install ``base_external_dbsource_mssql_by_odbc`` 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 <https://github.com/OCA/server-backend/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 <https://github.com/OCA/server-backend/issues/new?body=module:%20base_external_dbsource_mssql_by_odbc%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Open Source Integrators

Contributors
------------

- `Opensourceintegrators <https://www.opensourceintegrators.com>`__:

- Maxime Chambreuil <[email protected]>
- Nikul Chaudhary <[email protected]>

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-max3903| image:: https://github.com/max3903.png?size=40px
:target: https://github.com/max3903
:alt: max3903
.. |maintainer-Nikul-OSI| image:: https://github.com/Nikul-OSI.png?size=40px
:target: https://github.com/Nikul-OSI
:alt: Nikul-OSI

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-max3903| |maintainer-Nikul-OSI|

This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/18.0/base_external_dbsource_mssql_by_odbc>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions base_external_dbsource_mssql_by_odbc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions base_external_dbsource_mssql_by_odbc/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2025 Open Source Integrators (https://www.opensourceintegrators.com)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "External Database Source - MSSQL By ODBC",
"version": "18.0.1.0.0",
"category": "Tools",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"development_status": "Beta",
"maintainers": ["max3903", "Nikul-OSI"],
"website": "https://github.com/OCA/server-backend",
"license": "LGPL-3",
"depends": ["base_external_dbsource_mssql"],
"external_dependencies": {"python": ["pyodbc"]},
"demo": ["demo/base_external_dbsource.xml"],
"installable": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<odoo noupdate="1">
<record model="base.external.dbsource" id="demo_mssql_pyodbc">
<field name="name">MSSQL PyODBC Demo</field>
<field
name="conn_string"
>DRIVER={ODBC Driver 17 for SQL Server};SERVER=myServerAddress,port;DATABASE=myDataBase;UID=myUsernamea;PWD=%s;</field>
<field name="password">password</field>
<field name="connector">mssql_pyodbc</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions base_external_dbsource_mssql_by_odbc/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import base_external_dbsource
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (C) 2025 Open Source Integrators (https://www.opensourceintegrators.com)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import pyodbc

from odoo import fields, models


class BaseExternalDbsource(models.Model):
"""It provides logic for connection to a MSSQL data source."""

_inherit = "base.external.dbsource"

connector = fields.Selection(
selection_add=[("mssql_pyodbc", "Microsoft SQL Server (PyODBC)")],
ondelete={"mssql_pyodbc": "cascade"},
)
PWD_STRING_MSSQL_PYODBC = "Password=%s;"

def connection_close_mssql_pyodbc(self, connection):
return connection.close()

def connection_open_mssql_pyodbc(self):
return self._connection_open_mssql_pyodbc()

def execute_mssql_pyodbc(self, sqlquery, sqlparams, metadata):
return self._execute_mssql_pyodbc(sqlquery, sqlparams, metadata)

def _connection_open_mssql_pyodbc(self):
return pyodbc.connect(self.conn_string_full)

def _execute_mssql_pyodbc(self, sqlquery, sqlparams, metadata):
rows, cols = list(), list()
for record in self:
with record.connection_open() as connection:
cursor = connection.cursor()
if sqlparams is None:
cursor.execute(sqlquery)
else:
cursor.execute(sqlquery, sqlparams)
if metadata:
cols = [column[0] for column in cursor.description]
if (
cursor.description
): # description is only set for queries that return data
rows = cursor.fetchall()
else:
rows = list()
return rows, cols
3 changes: 3 additions & 0 deletions base_external_dbsource_mssql_by_odbc/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
4 changes: 4 additions & 0 deletions base_external_dbsource_mssql_by_odbc/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
To configure this module, you need to:

1. Database sources can be configured in Settings \> Technical \>
Database Structure \> Database sources.
4 changes: 4 additions & 0 deletions base_external_dbsource_mssql_by_odbc/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [Opensourceintegrators](https://www.opensourceintegrators.com):

- Maxime Chambreuil \<<[email protected]>\>
- Nikul Chaudhary \<<[email protected]>\>
2 changes: 2 additions & 0 deletions base_external_dbsource_mssql_by_odbc/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module extends `base_external_dbsource_mssql`, allowing you to connect to
foreign MSSQL databases using PyODBC.
5 changes: 5 additions & 0 deletions base_external_dbsource_mssql_by_odbc/readme/INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To install this module, you need to:

- Install & configure FreeTDS driver (tdsodbc package)
- Install `pyodbc` python libraries
- Install `base_external_dbsource_mssql_by_odbc` Odoo module
1 change: 1 addition & 0 deletions base_external_dbsource_mssql_by_odbc/readme/ROADMAP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add X.509 authentication
9 changes: 9 additions & 0 deletions base_external_dbsource_mssql_by_odbc/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading