提交 68e87866 authored 作者: 贺阳's avatar 贺阳

Merge branch 'develop' into feature/PDA扫码揽收

# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
...@@ -3,7 +3,7 @@ import asyncio ...@@ -3,7 +3,7 @@ import asyncio
import logging import logging
import ssl import ssl
from datetime import timedelta, datetime from datetime import timedelta, datetime
import json
import aiohttp import aiohttp
import certifi import certifi
import pytz import pytz
...@@ -261,6 +261,57 @@ class CcShipPackage(models.Model): ...@@ -261,6 +261,57 @@ class CcShipPackage(models.Model):
class CcBl(models.Model): class CcBl(models.Model):
_inherit = 'cc.bl' _inherit = 'cc.bl'
def custom_mawb_copy_upload(self, kw):
# 接收提单的附件信息
res = {
"code": 0,
"msg": "success",
}
try:
param_json = kw['param_json'] if kw.get('param_json') else {}
if param_json:
kws = param_json
# 根据kws中获取的master_waybill_no,在系统中查找提单,并将提单的信息更新
master_waybill_no = kws.get('master_waybill_no')
push_interval_15_days = self.env["ir.config_parameter"].sudo().get_param(
'tk_push_interval_15_days') or 15
# 当前时间-15天
date = fields.Datetime.now() - timedelta(days=int(push_interval_15_days))
bl = self.env['cc.bl'].sudo().search(
[('bl_no', '=', master_waybill_no), ('create_date', '>=', date)], limit=1)
if bl:
# 根据kws中获取的"img_detail"中的"img_file_code”和img_file_type,生成odoo的附件,并关联到cc.bl的bl_attachment_ids字段
vals = {'customs_bl_no': kws.get('customs_waybill_id'),
'transport_tool_code': kws.get('transport_code'),
'transport_tool_name': kws.get('transport_name'),
'end_port_code': kws.get('arrive_port_code')}
img_file_code = kws.get('img_detail').get('img_file_code')
img_file_type = kws.get('img_detail').get('img_file_type')
file_name = '%s.%s' % (
kws.get('master_waybill_no'), img_file_type)
img_file_vals = dict(name=file_name,
res_model='cc.bl',
res_id=bl.id,
type='binary',
datas=img_file_code,
mimetype='image/%s' % img_file_type)
img_file = self.env['ir.attachment'].sudo().create(
img_file_vals)
if img_file:
vals['bl_attachment_ids'] = [(6, 0, img_file.ids)]
bl.write(vals)
else:
res['code'] = 1009
res['msg'] = 'master_waybill_no [%s] not found.' % kws.get(
'master_waybill_no')
except Exception as e:
res['code'] = 5000
res['msg'] = 'system error: %s' % str(e)
logging.error('mawb_copy_upload error:%s' % str(e))
self._cr.rollback()
return res
# 计算未同步小包数量 # 计算未同步小包数量
@api.depends('ship_package_ids', 'ship_package_ids.is_sync') @api.depends('ship_package_ids', 'ship_package_ids.is_sync')
def _compute_unsync_package_count(self): def _compute_unsync_package_count(self):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论