提交 2e92ab17 authored 作者: 贺阳's avatar 贺阳

原功能批量获取尾程POD名称改为批量获取货站POD。并将获取的附件的位置由获取到尾程交接POD(待大包数量和箱号)改到货站提货POD上,并同步,其余功能不变。

修改翻译
上级 f20720ee
差异被折叠。
......@@ -722,7 +722,7 @@ class CcBL(models.Model):
def cron_get_pod(self):
"""
状态为清关中且附件信息尾程交接POD(待大包数量和箱号),为空的提单,自动获取尾程POD信息
状态为清关中且附件信息尾程交接POD(待大包数量和箱号),为空的提单,自动获取尾程POD信息 暂时不用
"""
fix_name = '尾程交接POD(待大包数量和箱号)'
bl_objs = self.env['cc.bl'].search(
......@@ -741,8 +741,7 @@ class CcBL(models.Model):
})
wizard_obj.confirm()
def _get_pod_files(self):
fix_name = '尾程交接POD(待大包数量和箱号)'
def _get_pod_files(self, fix_name):
res = []
for bl in self:
files = self.env['cc.clearance.file'].sudo().search(
......@@ -762,8 +761,13 @@ class CcBL(models.Model):
res.append((name, f.file))
return res
def action_download_pod(self):
files = self._get_pod_files()
def action_download_pod(self, pod_name):
"""
下载POD
:return:
"""
files = self._get_pod_files(pod_name)
if not files:
return {'type': 'ir.actions.act_window_close'}
if len(self) == 1 and len(files) == 1:
......@@ -1267,20 +1271,19 @@ class CcBL(models.Model):
'target': 'new'
}
def action_batch_download_pod(self):
def action_batch_download_pod(self, pod_name=''):
"""
将选中的提单以提单号命名下载尾程交接POD文件,若文件有多个则以提单-1/-2进行命名下载,若选择多个提单,则将所有文件打包成zip,zip命名则以POD进行命名
"""
# 检查是否有选中的提单
if not self:
raise UserError(_('Please select at least one bill of loading.'))
# 检查是否有尾程交接POD文件
fix_name = '尾程交接POD(待大包数量和箱号)'
# 检查是否有尾程交接POD文件或货站提货POD文件
has_files = self.env['cc.clearance.file'].search_count(
[('bl_id', 'in', self.ids), ('file_name', '=', fix_name), ('file', '!=', False)])
[('bl_id', 'in', self.ids), ('file_name', '=', pod_name), ('file', '!=', False)])
if not has_files:
raise UserError(_('Please configure the tail-end handover POD file of the bill of loading first.'))
return self.action_download_pod()
return self.action_download_pod(pod_name)
# 增加一个清关进度的业务对象,继承自models.Model, 用于管理业务数据.业务数据包括提单号、清关节点(业务对象)、进度日期、进度描述、更新人
......
......@@ -118,19 +118,17 @@ class OrderStateChangeRule(models.Model):
file_obj.is_upload = False
file_obj.action_sync()
def upload_pod_attachment(self, bl_obj, name, data):
"""尾程交接POD(待大包数量和箱号) 文件上传与同步"""
def upload_pod_attachment(self, bl_obj, name, data,file_name='货站提货POD'):
"""尾程交接POD(待大包数量和箱号)/货站提货POD 文件上传与同步"""
arr = [
{
'file_name': '尾程交接POD(待大包数量和箱号)',
'file_name': file_name,
'file': base64.encodebytes(data),
'attachment_name': name,
'is_upload': False,
'bl_id': bl.id
} for bl in bl_obj
]
# file_objs = self.env['cc.clearance.file'].sudo().search([('file_name', '=', '尾程交接POD(待大包数量和箱号)'),
# ('bl_id', 'in', bl_obj.ids)])
file_objs = self.env['cc.clearance.file'].sudo().create(arr)
# 最大重试次数
max_retries = 2
......@@ -138,10 +136,6 @@ class OrderStateChangeRule(models.Model):
retries = 0
while retries <= max_retries:
try:
# 设置文件内容
# file_obj.file = base64.encodebytes(data)
# file_obj.attachment_name = name
# file_obj.is_upload = False # 确保文件状态是未上传
# 尝试上传操作
file_obj.action_sync()
# 检查是否上传成功,假设 is_upload 为 False 表示上传失败
......
......@@ -412,9 +412,9 @@
</field>
</record>
<!-- 获取尾程POD -->
<!-- 获取货站提货POD -->
<record id="bl_get_pod_info_server_action" model="ir.actions.server">
<field name="name">Batch Get POD Info</field>
<field name="name">Batch Get PickUp POD Info</field>
<field name="model_id" ref="model_cc_bl"/>
<field name="binding_model_id" ref="model_cc_bl"/>
<field name="state">code</field>
......@@ -426,10 +426,23 @@
</field>
</record>
<!-- 获取尾程快递POD -->
<record id="bl_get_delivery_pod_info_server_action" model="ir.actions.server">
<field name="name">Batch Get Delivery POD Info</field>
<field name="model_id" ref="model_cc_bl"/>
<field name="binding_model_id" ref="model_cc_bl"/>
<field name="state">code</field>
<field name="binding_view_types">list,form</field>
<field name="groups_id" eval="[(4, ref('ccs_base.group_clearance_of_customs_user'))]"/>
<field name="code">
if records:
action = records.action_batch_get_pod_info()
</field>
</record>
<!-- 下载POD -->
<!-- 下载货站提货POD-->
<record id="bl_download_pod_server_action" model="ir.actions.server">
<field name="name">Batch Download POD</field>
<field name="name">Batch PickUp Download POD</field>
<field name="model_id" ref="model_cc_bl"/>
<field name="binding_model_id" ref="model_cc_bl"/>
<field name="state">code</field>
......@@ -437,8 +450,21 @@
<field name="groups_id" eval="[(4, ref('ccs_base.group_clearance_of_customs_user'))]"/>
<field name="code">
if records:
action = records.action_batch_download_pod()
action = records.action_batch_download_pod(pod_name='货站提货POD')
</field>
</record>
<!-- 下载尾程交接POD -->
<record id="bl_download_delivery_pod_server_action" model="ir.actions.server">
<field name="name">Batch Download Delivery POD</field>
<field name="model_id" ref="model_cc_bl"/>
<field name="binding_model_id" ref="model_cc_bl"/>
<field name="state">code</field>
<field name="binding_view_types">list,form</field>
<field name="groups_id" eval="[(4, ref('ccs_base.group_clearance_of_customs_user'))]"/>
<field name="code">
if records:
action = records.action_batch_download_pod(pod_name='尾程交接POD(待大包数量和箱号)')
</field>
</record>
</odoo>
\ No newline at end of file
......@@ -512,10 +512,11 @@ class BatchGetPodInfoWizard(models.TransientModel):
except requests.exceptions.RequestException as e:
raise ValidationError(_('API request failed: %s') % str(e))
def _write_pdf_file(self, processed_files):
def _write_pdf_file(self, processed_files, fix_name='货站提货POD'):
"""
Write PDF file to clearance files # 回写PDF文件到清关文件
:param processed_files: 处理后的文件数组
:param fix_name:
"""
for file_info in processed_files:
if not file_info.get('bl'):
......@@ -529,7 +530,6 @@ class BatchGetPodInfoWizard(models.TransientModel):
continue
# 如果有文件为空的就回写,否则就创建新的清关文件记录
fix_name = '尾程交接POD(待大包数量和箱号)'
clearance_file = self.env['cc.clearance.file'].search(
[('bl_id', '=', bl.id), ('file_name', '=', fix_name), ('file', '=', False)], limit=1)
if clearance_file:
......@@ -542,7 +542,7 @@ class BatchGetPodInfoWizard(models.TransientModel):
# 创建新的清关文件记录
clearance_file = self.env['cc.clearance.file'].create({
'bl_id': bl.id,
'file_name': '尾程交接POD(待大包数量和箱号)',
'file_name': fix_name,
'attachment_name': file_name,
'file': file_data
})
......
......@@ -36,10 +36,9 @@
Remove specified text (AGN, UCLINK LOGISITICS LTD) from PDF files
</li> <!-- 涂抹指定文字:对PDF文件中的指定文字进行涂抹处理 -->
<li attrs="{'invisible': [('sync_successful_processed', '=', False)]}">
<strong>Sync Last Mile POD:</strong>
Synchronize POD (Proof of Delivery) attachment information with TK system, including
big package quantities and container numbers
</li> <!-- 同步尾程POD:向TK同步尾程交接POD(待大包数量和箱号)的附件信息 -->
<strong>Sync Cargo Terminal Pickup POD:</strong>
Synchronize the attachment information of the POD for picking up goods from TK cargo station
</li> <!-- 同步货站提货POD:向TK同步货站提货POD的附件信息 -->
<li attrs="{'invisible': [('sync_successful_processed', '=', False)]}">
<strong>Sync Push Match Node:</strong>
......@@ -106,10 +105,9 @@
<strong>Description:</strong> <!-- 说明: -->
<ul>
<li>
<strong>Get Last Mile POD:</strong>
Generate a last mile POD (Proof of Delivery) attachment information, including
big package quantities and container numbers
</li> <!-- 获取尾程POD:生成一条尾程交接POD(待大包数量和箱号)的附件信息 -->
<strong>Get Cargo Terminal Pickup POD:</strong>
Generate a attachment information of the POD for picking up goods cargo station
</li> <!-- 获取货站提货POD:生成一条货站提货POD的附件信息 -->
<li attrs="{'invisible': [('get_last_mile_pod', '=', False)]}">
<strong>Remove Specified Text:</strong>
Remove specified text (AGN, UCLINK LOGISITICS LTD) from PDF files
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论