跳至内容
菜单
此问题已终结

Hi all,

I have written a controller to push the data to the client-side. The code is below. Can anybody please mention what is the error in this?



# -*- coding: utf-8 -*-
from odoo import http
import requests
import json
from odoo.http import request
from odoo import report as odoo_report
import datetime
import pytz
import base64
import logging

_logger = logging.getLogger(__name__)

url = 'https://*********/api/********logistics/fillshipmentdetails***'
authentication = '129487521452XSDFG156235C6B353CD75QWERBVFGHJAA96AA99EDSJUITH7AAF65258F22871E7D415EB4A77CF7B4CB513A993680FC6053EAE6RT785YUIJ124'

class MyApi(http.Controller):

@http.route("/my/post/api/path", url=url, auth="none", type='http', method=['POST'], csrf=False, cors='*')
def post_api_method(self, *kw):
partners = request['import.order'].sudo().search_read([('customer', '=', 'TRADING COMPANY')])

headers = {'Content-Type': 'application/json'}
body = {'results': {"shipmentType": partners.ship_Type,
"shipperName": partners.customer.name,
"consigneeName": "*****",
"vslexparvlDate": "2019-03-05 05:55:13:000",
"vsldischlDate": "2019-04-02 05:55:13:000",
"docRecvByMailDate": "2019-03-05 05:55:13:000",
"orgDocRecvgDate": "2019-03-24 05:55:13:000",
"vesselArvlDate": "2019-03-19 05:55:13:000",
"bLAwbNumber": "*****",
"houseBL": "****",
"dischargingPort": "*****",
"landingPort": "*****",
"containerNumber": "*****",
"delOrderDate": "2019-03-29 05:55:13:000",
"delOrderNumber": "******",
"bayanNumber": "*****",
"bayanDate": "2019-03-30 05:55:13:000",
"containerType": "*****",
"dutyPaidDate": "2019-03-22 05:55:13:000",
"transportNTFTerminal": "***",
"transportDirCustomer": "***",
"demmurageDate": "2019-03-27 05:55:13:000",
"lastDetentionDate": "2019-03-27 05:55:13:000",
"eIRReturnToShipLine": "****",
"eventUpdateStatus": "Delivered"
}}
response = requests.post(url, json.dumps(body), headers=headers)
return response


形象
丢弃

Please post the error message you are facing.

最佳答案

Hi  Pablo,

pls replace function "search_read" with "search" and try again. and feedback !


形象
丢弃
相关帖文 回复 查看 活动
0
11月 22
2487
0
2月 25
1483
0
10月 20
4642
0
10月 18
2933
1
4月 25
799