[IMP] tools/netsvc: removed direct dependency of tools on netsvc
bzr revid: vmt@openerp.com-20110126144255-t8p6g1ggjb7f1dmt
This commit is contained in:
parent
7bf401381d
commit
0e39f07490
|
@ -99,13 +99,13 @@ def amount_to_text(nbr, lang='en', currency='euro'):
|
|||
Example:
|
||||
1654: thousands six cent cinquante-quatre.
|
||||
"""
|
||||
import netsvc
|
||||
import loglevels
|
||||
# if nbr > 10000000:
|
||||
# netsvc.Logger().notifyChannel('translate', netsvc.LOG_WARNING, _("Number too large '%d', can not translate it"))
|
||||
# return str(nbr)
|
||||
|
||||
if not _translate_funcs.has_key(lang):
|
||||
netsvc.Logger().notifyChannel('translate', netsvc.LOG_WARNING, _("no translation function found for lang: '%s'" % (lang,)))
|
||||
loglevels.Logger().notifyChannel('translate', loglevels.LOG_WARNING, _("no translation function found for lang: '%s'" % (lang,)))
|
||||
#TODO: (default should be en) same as above
|
||||
lang = 'en'
|
||||
return _translate_funcs[lang](abs(nbr), currency)
|
||||
|
|
|
@ -41,7 +41,7 @@ except:
|
|||
from datetime import datetime, timedelta
|
||||
from lxml import etree
|
||||
import misc
|
||||
import netsvc
|
||||
import loglevels
|
||||
import osv
|
||||
import pooler
|
||||
from config import config
|
||||
|
@ -541,6 +541,7 @@ form: module.record_id""" % (xml_id,)
|
|||
id = _eval_xml(self, rec[0], self.pool, cr, self.uid, self.idref)
|
||||
|
||||
uid = self.get_uid(cr, self.uid, data_node, rec)
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, model,
|
||||
id,
|
||||
|
@ -688,7 +689,7 @@ form: module.record_id""" % (xml_id,)
|
|||
rec_src = rec.get("search",'').encode('utf8')
|
||||
rec_src_count = rec.get("count")
|
||||
|
||||
severity = rec.get("severity",'').encode('ascii') or netsvc.LOG_ERROR
|
||||
severity = rec.get("severity",'').encode('ascii') or loglevels.LOG_ERROR
|
||||
rec_string = rec.get("string",'').encode('utf8') or 'unknown'
|
||||
|
||||
ids = None
|
||||
|
@ -964,9 +965,9 @@ def convert_xml_import(cr, module, xmlfile, idref=None, mode='init', noupdate=Fa
|
|||
try:
|
||||
relaxng.assert_(doc)
|
||||
except Exception:
|
||||
logger = netsvc.Logger()
|
||||
logger.notifyChannel('init', netsvc.LOG_ERROR, 'The XML file does not fit the required schema !')
|
||||
logger.notifyChannel('init', netsvc.LOG_ERROR, misc.ustr(relaxng.error_log.last_error))
|
||||
logger = loglevels.Logger()
|
||||
logger.notifyChannel('init', loglevels.LOG_ERROR, 'The XML file does not fit the required schema !')
|
||||
logger.notifyChannel('init', loglevels.LOG_ERROR, misc.ustr(relaxng.error_log.last_error))
|
||||
raise
|
||||
|
||||
if idref is None:
|
||||
|
|
|
@ -55,7 +55,7 @@ try:
|
|||
except ImportError:
|
||||
html2text = None
|
||||
|
||||
import netsvc
|
||||
import loglevels
|
||||
from config import config
|
||||
from lru import LRU
|
||||
|
||||
|
@ -434,10 +434,10 @@ def _email_send(smtp_from, smtp_to_list, message, openobject_id=None, ssl=False,
|
|||
"""
|
||||
class WriteToLogger(object):
|
||||
def __init__(self):
|
||||
self.logger = netsvc.Logger()
|
||||
self.logger = loglevels.Logger()
|
||||
|
||||
def write(self, s):
|
||||
self.logger.notifyChannel('email_send', netsvc.LOG_DEBUG, s)
|
||||
self.logger.notifyChannel('email_send', loglevels.LOG_DEBUG, s)
|
||||
|
||||
if openobject_id:
|
||||
message['Message-Id'] = generate_tracking_message_id(openobject_id)
|
||||
|
@ -1094,7 +1094,7 @@ def logged(f):
|
|||
|
||||
vector.append(' result: %s' % pformat(res))
|
||||
vector.append(' time delta: %s' % (time.time() - timeb4))
|
||||
netsvc.Logger().notifyChannel('logged', netsvc.LOG_DEBUG, '\n'.join(vector))
|
||||
loglevels.Logger().notifyChannel('logged', loglevels.LOG_DEBUG, '\n'.join(vector))
|
||||
return res
|
||||
|
||||
return wrapper
|
||||
|
@ -1300,7 +1300,7 @@ def detect_server_timezone():
|
|||
try:
|
||||
import pytz
|
||||
except Exception:
|
||||
netsvc.Logger().notifyChannel("detect_server_timezone", netsvc.LOG_WARNING,
|
||||
loglevels.Logger().notifyChannel("detect_server_timezone", loglevels.LOG_WARNING,
|
||||
"Python pytz module is not available. Timezone will be set to UTC by default.")
|
||||
return 'UTC'
|
||||
|
||||
|
@ -1334,14 +1334,14 @@ def detect_server_timezone():
|
|||
if value:
|
||||
try:
|
||||
tz = pytz.timezone(value)
|
||||
netsvc.Logger().notifyChannel("detect_server_timezone", netsvc.LOG_INFO,
|
||||
loglevels.Logger().notifyChannel("detect_server_timezone", loglevels.LOG_INFO,
|
||||
"Using timezone %s obtained from %s." % (tz.zone,source))
|
||||
return value
|
||||
except pytz.UnknownTimeZoneError:
|
||||
netsvc.Logger().notifyChannel("detect_server_timezone", netsvc.LOG_WARNING,
|
||||
loglevels.Logger().notifyChannel("detect_server_timezone", loglevels.LOG_WARNING,
|
||||
"The timezone specified in %s (%s) is invalid, ignoring it." % (source,value))
|
||||
|
||||
netsvc.Logger().notifyChannel("detect_server_timezone", netsvc.LOG_WARNING,
|
||||
loglevels.Logger().notifyChannel("detect_server_timezone", loglevels.LOG_WARNING,
|
||||
"No valid timezone could be detected, using default UTC timezone. You can specify it explicitly with option 'timezone' in the server configuration.")
|
||||
return 'UTC'
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ from datetime import datetime
|
|||
from lxml import etree
|
||||
|
||||
import tools
|
||||
import netsvc
|
||||
from tools.misc import UpdateableStr
|
||||
from tools.misc import SKIPPED_ELEMENT_TYPES
|
||||
|
||||
|
@ -587,6 +586,7 @@ def trans_generate(lang, modules, cr):
|
|||
push_translation(module, 'view', encode(obj.model), 0, t)
|
||||
elif model=='ir.actions.wizard':
|
||||
service_name = 'wizard.'+encode(obj.wiz_name)
|
||||
import netsvc
|
||||
if netsvc.Service._services.get(service_name):
|
||||
obj2 = netsvc.Service._services[service_name]
|
||||
for state_name, state_def in obj2.states.iteritems():
|
||||
|
|
|
@ -5,7 +5,6 @@ from datetime import datetime, timedelta
|
|||
import logging
|
||||
|
||||
import pooler
|
||||
import netsvc
|
||||
import misc
|
||||
from config import config
|
||||
import yaml_tag
|
||||
|
@ -448,6 +447,7 @@ class YamlInterpreter(object):
|
|||
signals=[x['signal'] for x in self.cr.dictfetchall()]
|
||||
if workflow.action not in signals:
|
||||
raise YamlImportException('Incorrect action %s. No such action defined' % workflow.action)
|
||||
import netsvc
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, workflow.model, id, workflow.action, self.cr)
|
||||
|
||||
|
|
Loading…
Reference in New Issue