2017-12-11 10:14:07 +01:00
|
|
|
# The COPYRIGHT file at the top level of this repository contains the full
|
|
|
|
# copyright notices and license terms.
|
|
|
|
from trytond.pool import PoolMeta
|
|
|
|
from trytond.model import fields
|
|
|
|
from .connector import BackendConnectorMSsql
|
|
|
|
|
|
|
|
__all__ = ['Instance']
|
2017-12-14 18:03:11 +01:00
|
|
|
|
2017-12-11 10:14:07 +01:00
|
|
|
MS_URL = "mssql://ipServer:1433/database"
|
|
|
|
|
|
|
|
|
2019-02-28 13:56:46 +01:00
|
|
|
class Instance(metaclass=PoolMeta):
|
2017-12-11 10:14:07 +01:00
|
|
|
__name__ = 'edw.instance'
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def __setup__(cls):
|
|
|
|
super(Instance, cls).__setup__()
|
2017-12-14 18:03:11 +01:00
|
|
|
sql_type = ('mssql', 'MS SQL Server')
|
2017-12-11 10:14:07 +01:00
|
|
|
cls.type_.selection.append(sql_type)
|
|
|
|
|
|
|
|
@fields.depends('uri')
|
|
|
|
def on_change_type_(self):
|
|
|
|
if not self.uri:
|
|
|
|
self.uri = MS_URL
|
|
|
|
|
|
|
|
def get_app_connector(self):
|
|
|
|
if self.type_ == 'mssql':
|
|
|
|
return BackendConnectorMSsql(self.uri,
|
|
|
|
username=self.user,
|
|
|
|
password=self.pwd)
|
2017-12-14 18:03:11 +01:00
|
|
|
return super(Instance, self).get_app_connector()
|