获取面单接口已跑通
This commit is contained in:
@@ -5,6 +5,7 @@ import jionlp as jio
|
|||||||
import logging
|
import logging
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
import requests
|
import requests
|
||||||
|
import base64
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -26,7 +27,9 @@ class JdEclp(models.Model):
|
|||||||
expressItemName = fields.Char(string='货物名称', required=True, default='非标工件')
|
expressItemName = fields.Char(string='货物名称', required=True, default='非标工件')
|
||||||
pickupBeginTime = fields.Char(string='期望取件时间')
|
pickupBeginTime = fields.Char(string='期望取件时间')
|
||||||
deliveryType = fields.Selection([('6', '特快零担'), ('25', '特快重货')], string='运输类型', default='25')
|
deliveryType = fields.Selection([('6', '特快零担'), ('25', '特快重货')], string='运输类型', default='25')
|
||||||
bill = fields.Char(string='快递面单')
|
bill = fields.Char(string='物流面单')
|
||||||
|
|
||||||
|
# bill = fields.Many2one('ir.attachment', string='物流面单')
|
||||||
|
|
||||||
@api.depends('origin')
|
@api.depends('origin')
|
||||||
def _truck_info(self):
|
def _truck_info(self):
|
||||||
@@ -92,5 +95,30 @@ class JdEclp(models.Model):
|
|||||||
'no': self.origin,
|
'no': self.origin,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
url1 = 'https://bfm.cs.jikimo.com/api/api/create/jd/bill'
|
url1 = 'https://bfm.cs.jikimo.com/api/create/jd/bill'
|
||||||
requests.post(url1, json=json1, data=None)
|
response = requests.post(url1, json=json1, data=None)
|
||||||
|
# _logger.info('调用成功2', response.json())
|
||||||
|
|
||||||
|
# _logger.info('调用成功2', response.text)
|
||||||
|
bill_url_str = response.json()['result']['jingdong_eclp_co_generateBdWayBillFile_responce']['result']['content']
|
||||||
|
bill_url = 'http:' + bill_url_str
|
||||||
|
data = base64.b64encode(requests.get(bill_url).content)
|
||||||
|
# self.bill = bill_url
|
||||||
|
_logger.info('调用成功2')
|
||||||
|
attachment = self.env['ir.attachment'].sudo().create({
|
||||||
|
'datas': data,
|
||||||
|
'type': 'binary',
|
||||||
|
'description': '快递面单',
|
||||||
|
'name': self.carrier_tracking_ref,
|
||||||
|
# 'res_id': invoice.id,
|
||||||
|
# 'res_model': 'stock.picking',
|
||||||
|
'public': True,
|
||||||
|
'mimetype': 'application/pdf',
|
||||||
|
# 'model_name': 'stock.picking',
|
||||||
|
})
|
||||||
|
_logger.info(attachment)
|
||||||
|
# _logger.info(attachment.datas)
|
||||||
|
# _logger.info(attachment.datas_fname)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
<field name="grossWeight"/>
|
<field name="grossWeight"/>
|
||||||
<field name="grossVolume"/>
|
<field name="grossVolume"/>
|
||||||
<field name="pickupBeginTime"/>
|
<field name="pickupBeginTime"/>
|
||||||
|
<field name="bill"/>
|
||||||
|
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//group[@name='other_infos']" position="after">
|
<xpath expr="//group[@name='other_infos']" position="after">
|
||||||
|
|||||||
Reference in New Issue
Block a user