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

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

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