[IMP] account_voucher: added case2_usd_eur_debtor_in_eur.yml
[odoo/odoo.git] / openerp / netsvc.py
index 7f81228..8d11891 100644 (file)
@@ -37,7 +37,6 @@ from pprint import pformat
 # TODO modules that import netsvc only for things from loglevels must be changed to use loglevels.
 from loglevels import *
 import tools
-import openerp.exceptions
 
 def close_socket(sock):
     """ Closes a socket instance cleanly
@@ -61,12 +60,11 @@ def close_socket(sock):
 #.apidoc title: Common Services: netsvc
 #.apidoc module-mods: member-order: bysource
 
-def abort_response(dummy_1, description, dummy_2, details):
-    # TODO Replace except_{osv,orm} with these directly.
-    if description == 'AccessError':
-        raise openerp.exceptions.AccessError(details)
+def abort_response(error, description, origin, details):
+    if not tools.config['debug_mode']:
+        raise Exception("%s -- %s\n\n%s"%(origin, description, details))
     else:
-        raise openerp.exceptions.Warning(details)
+        raise
 
 class Service(object):
     """ Base class for *Local* services
@@ -98,9 +96,12 @@ def LocalService(name):
 class ExportService(object):
     """ Proxy for exported services.
 
+    All methods here should take an AuthProxy as their first parameter. It
+    will be appended by the calling framework.
+
     Note that this class has no direct proxy, capable of calling
     eservice.method(). Rather, the proxy should call
-    dispatch(method, params)
+    dispatch(method,auth,params)
     """
 
     _services = {}
@@ -117,7 +118,7 @@ class ExportService(object):
 
     # Dispatch a RPC call w.r.t. the method name. The dispatching
     # w.r.t. the service (this class) is done by OpenERPDispatcher.
-    def dispatch(self, method, params):
+    def dispatch(self, method, auth, params):
         raise Exception("stub dispatch at %s" % self.__name)
 
 BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, _NOTHING, DEFAULT = range(10)
@@ -392,7 +393,7 @@ def log(title, msg, channel=logging.DEBUG_RPC, depth=None, fn=""):
             logger.log(channel, indent+line)
             indent=indent_after
 
-def dispatch_rpc(service_name, method, params):
+def dispatch_rpc(service_name, method, params, auth):
     """ Handle a RPC call.
 
     This is pure Python code, the actual marshalling (from/to XML-RPC or
@@ -407,7 +408,7 @@ def dispatch_rpc(service_name, method, params):
             _log('service', tuple(replace_request_password(params)), depth=None, fn='%s.%s'%(service_name,method))
         if logger.isEnabledFor(logging.DEBUG_RPC):
             start_time = time.time()
-        result = ExportService.getService(service_name).dispatch(method, params)
+        result = ExportService.getService(service_name).dispatch(method, auth, params)
         if logger.isEnabledFor(logging.DEBUG_RPC):
             end_time = time.time()
         if not logger.isEnabledFor(logging.DEBUG_RPC_ANSWER):
@@ -415,12 +416,6 @@ def dispatch_rpc(service_name, method, params):
         _log('execution time', '%.3fs' % (end_time - start_time), channel=logging.DEBUG_RPC_ANSWER)
         _log('result', result, channel=logging.DEBUG_RPC_ANSWER)
         return result
-    except openerp.exceptions.AccessError:
-        raise
-    except openerp.exceptions.AccessDenied:
-        raise
-    except openerp.exceptions.Warning:
-        raise
     except Exception, e:
         _log('exception', tools.exception_to_unicode(e))
         tb = getattr(e, 'traceback', sys.exc_info())