mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-21 23:32:01 +02:00
Initial commit: Core packages
This commit is contained in:
commit
12c29a983b
9512 changed files with 8379910 additions and 0 deletions
58
odoo-bringout-oca-ocb-base/odoo/service/common.py
Normal file
58
odoo-bringout-oca-ocb-base/odoo/service/common.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
import odoo.release
|
||||
import odoo.tools
|
||||
from odoo.exceptions import AccessDenied
|
||||
from odoo.tools.translate import _
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
RPC_VERSION_1 = {
|
||||
'server_version': odoo.release.version,
|
||||
'server_version_info': odoo.release.version_info,
|
||||
'server_serie': odoo.release.serie,
|
||||
'protocol_version': 1,
|
||||
}
|
||||
|
||||
def exp_login(db, login, password):
|
||||
return exp_authenticate(db, login, password, None)
|
||||
|
||||
def exp_authenticate(db, login, password, user_agent_env):
|
||||
if not user_agent_env:
|
||||
user_agent_env = {}
|
||||
res_users = odoo.registry(db)['res.users']
|
||||
try:
|
||||
return res_users.authenticate(db, login, password, {**user_agent_env, 'interactive': False})
|
||||
except AccessDenied:
|
||||
return False
|
||||
|
||||
def exp_version():
|
||||
return RPC_VERSION_1
|
||||
|
||||
def exp_about(extended=False):
|
||||
"""Return information about the OpenERP Server.
|
||||
|
||||
@param extended: if True then return version info
|
||||
@return string if extended is False else tuple
|
||||
"""
|
||||
|
||||
info = _('See http://openerp.com')
|
||||
|
||||
if extended:
|
||||
return info, odoo.release.version
|
||||
return info
|
||||
|
||||
def exp_set_loglevel(loglevel, logger=None):
|
||||
# TODO Previously, the level was set on the now deprecated
|
||||
# `odoo.netsvc.Logger` class.
|
||||
return True
|
||||
|
||||
def dispatch(method, params):
|
||||
g = globals()
|
||||
exp_method_name = 'exp_' + method
|
||||
if exp_method_name in g:
|
||||
return g[exp_method_name](*params)
|
||||
else:
|
||||
raise Exception("Method not found: %s" % method)
|
||||
Loading…
Add table
Add a link
Reference in a new issue