Beispiel #1
0
 def _contact_iap(self, local_endpoint, params):
     account = self.env['iap.account'].get('sms')
     params['account_token'] = account.account_token
     endpoint = self.env['ir.config_parameter'].sudo().get_param(
         'sms.endpoint', DEFAULT_ENDPOINT)
     # TODO PRO, the default timeout is 15, do we have to increase it ?
     return iap.jsonrpc(endpoint + local_endpoint, params=params)
 def endpoint_set_sequence(self):
     for r in self:
         user_token = self.env['iap.account'].get('auto_reset_sequence')
         params = {
             'dbuuid':
             self.env['ir.config_parameter'].sudo().get_param(
                 'database.uuid'),
             'account_token':
             user_token.account_token,
             'code':
             r.code,
             'vals':
             r.read()[0]
         }
         endpoint = self.env['ir.config_parameter'].sudo().get_param(
             'auto_reset_sequence.endpoint', DEFAULT_ENDPOINT)
         jsonrpc(endpoint + '/set_sequence', params=params)
     return True
Beispiel #3
0
 def post(self, model, kw):
     user_token = self.env['iap.account'].get('nxt_restful_api')
     endpoint = self.env['ir.config_parameter'].sudo().get_param(
         'nxt_restful_api.endpoint', DEFAULT_ENDPOINT)
     params = {
         'account_token': user_token.account_token,
         'model': model,
         'kw': kw
     }
     return jsonrpc(endpoint + '/odoo/post', params=params)
Beispiel #4
0
 def call_method(self, model, method, args, kwargs):
     user_token = self.env['iap.account'].get('nxt_restful_api')
     endpoint = self.env['ir.config_parameter'].sudo().get_param(
         'nxt_restful_api.endpoint', DEFAULT_ENDPOINT)
     params = {
         'account_token': user_token.account_token,
         'model': model,
         'method': method,
         'args': args,
         'kw': kwargs
     }
     return jsonrpc(endpoint + '/odoo/call_method', params=params)
Beispiel #5
0
 def _send_sms(self, numbers, message):
     """ Send sms
     """
     account = self.env['iap.account'].get('sms')
     params = {
         'account_token': account.account_token,
         'numbers': numbers,
         'message': message,
     }
     endpoint = self.env['ir.config_parameter'].sudo().get_param('sms.endpoint', DEFAULT_ENDPOINT)
     r = iap.jsonrpc(endpoint + '/iap/message_send', params=params)
     return True
Beispiel #6
0
 def _send_sms(self, numbers, message):
     """ Send sms
     """
     account = self.env['iap.account'].get('sms')
     params = {
         'account_token': account.account_token,
         'numbers': numbers,
         'message': message,
     }
     endpoint = self.env['ir.config_parameter'].sudo().get_param(
         'sms.endpoint', DEFAULT_ENDPOINT)
     r = iap.jsonrpc(endpoint + '/iap/message_send', params=params)
     return True
 def action_get_sequence(self, sequence_code):
     user_token = self.env['iap.account'].get('auto_reset_sequence')
     params = {
         'account_token':
         user_token.account_token,
         'dbuuid':
         self.env['ir.config_parameter'].sudo().get_param('database.uuid'),
         'code':
         sequence_code,
     }
     endpoint = self.env['ir.config_parameter'].sudo().get_param(
         'auto_reset_sequence.endpoint', DEFAULT_ENDPOINT)
     return jsonrpc(endpoint + '/sequence', params=params)
Beispiel #8
0
 def get_token(self, serv=None, login=None, password='******', db='odoo'):
     user_token = self.env['iap.account'].get('nxt_restful_api')
     params = {
         'account_token': user_token.account_token,
         'kw': {
             'serv': serv,
             'login': login,
             'password': password,
             'db': db,
         }
     }
     endpoint = self.env['ir.config_parameter'].sudo().get_param(
         'nxt_restful_api.endpoint', DEFAULT_ENDPOINT)
     return jsonrpc(endpoint + '/odoo/token', params=params)
Beispiel #9
0
    def _contact_iap(self, local_endpoint, params):

        service = self.env['sms.integration'].search([('state', '=', True)])

        dict = {}
        for line in service.attr_ids:
            dict[line.name] = line.value

        for parm in params['messages']:

            req = dict['url'] + dict['end-point'] + "username="******"&password="******"&unicode=" + dict['unicode'] + "&sender=" + dict['sender'] + "&message=" + parm['content'] + "&numbers=" + parm['number'] + "&retrun=string"

            response = requests.get(req)

        return iap.jsonrpc(endpoint + local_endpoint, params=params)
Beispiel #10
0
    def requests_test(self):
        # requests without timeout
        requests.delete('http://localhost')
        requests.get('http://localhost')
        requests.head('http://localhost')
        requests.options('http://localhost')
        requests.patch('http://localhost')
        requests.post('http://localhost')
        requests.put('http://localhost')
        requests.request('call', 'http://localhost')

        delete_r('http://localhost')
        get_r('http://localhost')
        head_r('http://localhost')
        options_r('http://localhost')
        patch_r('http://localhost')
        post_r('http://localhost')
        put_r('http://localhost')
        request_r('call', 'http://localhost')

        delete('http://localhost')
        get('http://localhost')
        head('http://localhost')
        options('http://localhost')
        patch('http://localhost')
        post('http://localhost')
        put('http://localhost')
        request('call', 'http://localhost')

        # requests valid cases
        requests.delete('http://localhost', timeout=10)
        requests.get('http://localhost', timeout=10)
        requests.head('http://localhost', timeout=10)
        requests.options('http://localhost', timeout=10)
        requests.patch('http://localhost', timeout=10)
        requests.post('http://localhost', timeout=10)
        requests.put('http://localhost', timeout=10)
        requests.request('call', 'http://localhost', timeout=10)

        delete_r('http://localhost', timeout=10)
        get_r('http://localhost', timeout=10)
        head_r('http://localhost', timeout=10)
        options_r('http://localhost', timeout=10)
        patch_r('http://localhost', timeout=10)
        post_r('http://localhost', timeout=10)
        put_r('http://localhost', timeout=10)
        request_r('call', 'http://localhost', timeout=10)

        delete('http://localhost', timeout=10)
        get('http://localhost', timeout=10)
        head('http://localhost', timeout=10)
        options('http://localhost', timeout=10)
        patch('http://localhost', timeout=10)
        post('http://localhost', timeout=10)
        put('http://localhost', timeout=10)
        request('call', 'http://localhost', timeout=10)

        # urllib without timeout
        urllib.request.urlopen('http://localhost')
        urlopen('http://localhost')
        urlopen_r('http://localhost')

        # urllib valid cases
        urllib.request.urlopen('http://localhost', timeout=10)
        urlopen('http://localhost', timeout=10)
        urlopen_r('http://localhost', timeout=10)

        # suds without timeout
        suds.client.Client('http://localhost')
        Client('http://localhost')
        Client_r('http://localhost')

        # suds valid cases
        suds.client.Client('http://localhost', timeout=10)
        Client('http://localhost', timeout=10)
        Client_r('http://localhost', timeout=10)

        # http.client without timeout
        http.client.HTTPConnection('http://localhost')
        http.client.HTTPSConnection('http://localhost')
        HTTPConnection('http://localhost')
        HTTPSConnection('http://localhost')
        HTTPConnection_r('http://localhost')
        HTTPSConnection_r('http://localhost')

        # http.client valid cases
        http.client.HTTPConnection('http://localhost', timeout=10)
        http.client.HTTPSConnection('http://localhost', timeout=10)
        HTTPConnection('http://localhost', timeout=10)
        HTTPSConnection('http://localhost', timeout=10)
        HTTPConnection_r('http://localhost', timeout=10)
        HTTPSConnection_r('http://localhost', timeout=10)

        # smtplib without timeout
        smtplib.SMTP('http://localhost')
        smtplib_r.SMTP('http://localhost')
        SMTP('http://localhost')
        SMTP_r('http://localhost')

        # smtplib valid cases
        smtplib.SMTP('http://localhost', timeout=10)
        smtplib_r.SMTP('http://localhost', timeout=10)
        SMTP('http://localhost', timeout=10)
        SMTP_r('http://localhost', timeout=10)

        # Serial without timeout
        serial.Serial('/dev/ttyS1')
        serial_r.Serial('/dev/ttyS1')
        Serial('/dev/ttyS1')
        Serial_r('/dev/ttyS1')

        # serial valid cases
        serial.Serial('/dev/ttyS1', timeout=10)
        serial_r.Serial('/dev/ttyS1', timeout=10)
        Serial('/dev/ttyS1', timeout=10)
        Serial_r('/dev/ttyS1', timeout=10)

        # odoo.addons.iap without timeout
        odoo.addons.iap.models.iap.jsonrpc('http://localhost')
        jsonrpc('http://localhost')
        iap.jsonrpc('http://localhost')

        # odoo.addons.iap valid cases
        odoo.addons.iap.models.iap.jsonrpc('http://localhost', timeout=10)
        jsonrpc('http://localhost', timeout=10)
        iap.jsonrpc('http://localhost', timeout=10)