Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to handle a rpc call in OpenERP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 370
    Comment on it

    In OpenERP rpc help to change the post, like user want to excute two server in same systems then use rpc and change port number of other server. Basically rpc is used to run server in local systems.

    Use this function given below

    def rpc(service_name, method, params):
    
        try:
            rpc_request = logging.getLogger(__name__ + '.rpc.request')
            rpc_response = logging.getLogger(__name__ + '.rpc.response')
            rpc_request_flag = rpc_request.isEnabledFor(logging.DEBUG)
            rpc_response_flag = rpc_response.isEnabledFor(logging.DEBUG)
            if rpc_request_flag or rpc_response_flag:
                start_time = time.time()
                if rpc_request and rpc_response_flag:
                    log(rpc_request,logging.DEBUG,'%s.%s'%(service_name,method), replace_request_password(params))
    
            result = ExportService.gedef dispatch_rpc(service_name, method, params):
    
        try:
            rpc_request = logging.getLogger(__name__ + '.rpc.request')
            rpc_response = logging.getLogger(__name__ + '.rpc.response')
            rpc_request_flag = rpc_request.isEnabledFor(logging.DEBUG)
            rpc_response_flag = rpc_response.isEnabledFor(logging.DEBUG)
            if rpc_request_flag or rpc_response_flag:
                start_time = time.time()
                if rpc_request and rpc_response_flag:
                    log(rpc_request,logging.DEBUG,'%s.%s'%(service_name,method), replace_request_password(params))
    
            result = ExportService.getService(service_name).dispatch(method, params)
    
            if rpc_request_flag or rpc_response_flag:
                end_time = time.time()
                if rpc_response_flag:
                    log(rpc_response,logging.DEBUG,'%s.%s time:%.3fs '%(service_name,method,end_time - start_time), result)
                else:
                    log(rpc_request,logging.DEBUG,'%s.%s time:%.3fs '%(service_name,method,end_time - start_time), replace_request_password(params), depth=1)
    
            return result
        except openerp.exceptions.AccessError:
            raise
        except openerp.exceptions.AccessDenied:
            raise
        except openerp.exceptions.Warning:
            raise
        except openerp.exceptions.DeferredException, e:
            _logger.error(tools.exception_to_unicode(e))
            post_mortem(e.traceback)
            raise
        except Exception, e:
            _logger.error(tools.exception_to_unicode(e))
            post_mortem(sys.exc_info())
            raise
    
    tService(service_name).dispatch(method, params)
    
            if rpc_request_flag or rpc_response_flag:
                end_time = time.time()
                if rpc_response_flag:
                    log(rpc_response,logging.DEBUG,'%s.%s time:%.3fs '%(service_name,method,end_time - start_time), result)
                else:
                    log(rpc_request,logging.DEBUG,'%s.%s time:%.3fs '%(service_name,method,end_time - start_time), replace_request_password(params), depth=1)
    
            return result
        except openerp.exceptions.AccessError:
            raise
        except openerp.exceptions.AccessDenied:
            raise
        except openerp.exceptions.Warning:
            raise
        except openerp.exceptions.DeferredException, e:
            _logger.error(tools.exception_to_unicode(e))
            post_mortem(e.traceback)
            raise
        except Exception, e:
            _logger.error(tools.exception_to_unicode(e))
            post_mortem(sys.exc_info())
            raise
    
    

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: