在odoo python中使用jsonrpc

时间:2018-11-30 07:34:51

标签: python json-rpc odoo-12

我正在使用jtable在odoo12 Web控制器文件中使用jsonrpc在网站中加载报价单。这是我的python代码。

我的python代码-

@http.route(['/Quotation/List'], type='http', auth='public', 
website=True, csrf=False)

def quotation_list(self, **post):
  vals = []
  set_data_in_dic_json = {}
  url = "http://localhost:8082/quotations"
  headers = {'Content-Type': 'application/json'}
  total_list = sale_obj.search([('state', 'in', ('draft', 'sent'))])
  quotation_list = sale_obj.search([('state', 'in', ('draft', 'sent'))],offset=int(jtStartIndex), limit=int(jtPageSize), order=jtSorting)
  if quotation_list:
        for user_data in quotation_list:
            sale_date = user_data.date_order
            user_dic = {}
            user_dic['id'] = user_data.id
            user_dic['name'] = user_data.name
            user_dic['date_order'] = str(sale_date)
            user_dic['RequestDate'] = ''
            user_dic['partner_id'] = user_data.partner_id.name
            user_dic['user_id'] = user_data.user_id.name
            user_dic['amount_total'] = user_data.amount_total
            user_dic['state'] = user_data.state
            vals.append(user_dic)
  set_data_in_dic_json['Result'] = "OK"
  set_data_in_dic_json['TotalRecordCount'] = len(total_list)
  set_data_in_dic_json['Records'] = vals
  data = {
    "method": "echo",
    "params": set_data_in_dic_json,
    "jsonrpc": "2.0",
    "id": 0,
    }
  data_json = json.dumps(data)
  response = requests.post(url, data=data_json, headers=headers)
  c = response.text
  print (c)

该语句显示如下错误:

{“ id”:0,“ jsonrpc”:“ 2.0”,“错误”:{“代码”:404,“ http_status”:404,“消息”:“ 404:未找到”,“数据”: {“ exception_type”:“ internal_error”,“ debug”:“跟踪(最近一次通话最近):\ n文件\” / home / priya / workspace / odoo12 / odoo / http.py \”,_ handle_exception中的第653行\ n返回超级(JsonRequest,自身)。_handle_exception(异常)\ n文件” /home/priya/workspace/odoo12/odoo/http.py \”,第312行,在_handle_exception中\ n提高pycompat.reraise(类型(异常),例外,sys.exc_info()[2])\ n文件\“ / home / priya / workspace / odoo12 / odoo / tools / pycompat.py \”,第87行,在重新筹款\ n提高价值\ n文件\ “ /home/priya/workspace/odoo12/odoo/http.py \”,行1457,在_dispatch_nodb \ n函数中,参数= self.nodb_routing_map.bind_to_environ(request.httprequest.environ).match()\ n文件\“ /home/priya/.local/lib/python3.5/site-packages/werkzeug/routing.py \“,第1581行,在match \ n中引发NotFound()\ nwerkzeug.exceptions.NotFound:404未找到:请求的在伺服器上找不到网址版本如果您手动输入URL,请检查拼写,然后重试。\ n“,”消息“:” 404找不到:在服务器上找不到请求的URL。如果您手动输入了URL,请检查拼写,然后重试。“,” name“:” werkzeug.exceptions.NotFound“,” arguments“:[]}}}

0 个答案:

没有答案