Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
91014d40
提交
91014d40
authored
12月 03, 2025
作者:
贺阳
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1、将选中的提单以提单号命名下载尾程交接POD文件,若文件有多个则以提单-1/-2进行命名下载,若选择多个提单,则将所有文件打包成zip,zip命名则以POD进行命名
2、预览和确认的优化
上级
ee754777
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
68 行增加
和
48 行删除
+68
-48
cc_bill_loading.py
ccs_base/models/cc_bill_loading.py
+59
-1
cc_bl_view.xml
ccs_base/views/cc_bl_view.xml
+6
-46
batch_get_pod_info_wizard.py
ccs_base/wizard/batch_get_pod_info_wizard.py
+0
-0
batch_get_pod_info_wizard_views.xml
ccs_base/wizard/batch_get_pod_info_wizard_views.xml
+3
-1
没有找到文件。
ccs_base/models/cc_bill_loading.py
浏览文件 @
91014d40
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
import
json
import
json
import
logging
import
logging
from
datetime
import
timedelta
from
datetime
import
timedelta
import
base64
import
io
import
zipfile
import
pytz
import
pytz
from
odoo
import
models
,
fields
,
api
,
_
from
odoo
import
models
,
fields
,
api
,
_
...
@@ -737,6 +740,45 @@ class CcBL(models.Model):
...
@@ -737,6 +740,45 @@ class CcBL(models.Model):
'sync_match_node'
:
True
'sync_match_node'
:
True
})
})
wizard_obj
.
confirm
()
wizard_obj
.
confirm
()
def
_get_pod_files
(
self
):
fix_name
=
'尾程交接POD(待大包数量和箱号)'
res
=
[]
for
bl
in
self
:
files
=
self
.
env
[
'cc.clearance.file'
]
.
sudo
()
.
search
([(
'bl_id'
,
'='
,
bl
.
id
),
(
'file_name'
,
'='
,
fix_name
),
(
'file'
,
'!='
,
False
)])
if
not
files
:
continue
total
=
len
(
files
)
idx
=
0
for
f
in
files
:
idx
+=
1
base
=
bl
.
bl_no
or
str
(
bl
.
id
)
ext
=
'pdf'
if
f
.
attachment_name
and
'.'
in
f
.
attachment_name
:
ext
=
f
.
attachment_name
.
split
(
'.'
)[
-
1
]
name
=
f
"{base}.{ext}"
if
total
==
1
else
f
"{base}-{idx}.{ext}"
res
.
append
((
name
,
f
.
file
))
return
res
def
action_download_pod
(
self
):
files
=
self
.
_get_pod_files
()
if
not
files
:
return
{
'type'
:
'ir.actions.act_window_close'
}
if
len
(
self
)
==
1
and
len
(
files
)
==
1
:
name
,
data_b64
=
files
[
0
]
att
=
self
.
env
[
'ir.attachment'
]
.
sudo
()
.
create
({
'name'
:
name
,
'datas'
:
data_b64
,
'res_model'
:
'cc.bl'
,
'res_id'
:
self
.
id
,
'mimetype'
:
'application/pdf'
})
url
=
f
"/web/content/ir.attachment/{att.id}/datas/{att.name}?download=true"
return
{
'type'
:
'ir.actions.act_url'
,
'url'
:
url
,
'target'
:
'self'
}
buf
=
io
.
BytesIO
()
with
zipfile
.
ZipFile
(
buf
,
'w'
,
compression
=
zipfile
.
ZIP_DEFLATED
)
as
zf
:
for
name
,
data_b64
in
files
:
zf
.
writestr
(
name
,
base64
.
b64decode
(
data_b64
))
datas
=
base64
.
b64encode
(
buf
.
getvalue
())
att
=
self
.
env
[
'ir.attachment'
]
.
sudo
()
.
create
({
'name'
:
'POD.zip'
,
'datas'
:
datas
,
'res_model'
:
'cc.bl'
,
'res_id'
:
self
[
0
]
.
id
,
'mimetype'
:
'application/zip'
})
url
=
f
"/web/content/ir.attachment/{att.id}/datas/{att.name}?download=true"
return
{
'type'
:
'ir.actions.act_url'
,
'url'
:
url
,
'target'
:
'self'
}
def
action_package_pod
(
self
,
ids
):
return
self
.
browse
(
ids
)
.
action_download_pod
()
# 增加一个can_cancel的方法,用于检查提单当前是否可以取消,返回True表示可以取消, False表示不可以取消,同时返回取消的原因
# 增加一个can_cancel的方法,用于检查提单当前是否可以取消,返回True表示可以取消, False表示不可以取消,同时返回取消的原因
def
check_cancel
(
self
):
def
check_cancel
(
self
):
...
@@ -1179,7 +1221,7 @@ class CcBL(models.Model):
...
@@ -1179,7 +1221,7 @@ class CcBL(models.Model):
'view_mode'
:
'form'
,
'view_mode'
:
'form'
,
'res_model'
:
'batch.get.pod.info.wizard'
,
'res_model'
:
'batch.get.pod.info.wizard'
,
'context'
:
{
'active_id'
:
self
.
ids
,
'default_action_type'
:
'获取尾程POD信息'
},
'context'
:
{
'active_id'
:
self
.
ids
,
'default_action_type'
:
'获取尾程POD信息'
},
'view
_id'
:
self
.
env
.
ref
(
'ccs_base.view_batch_get_pod_info_wizard_form'
)
.
id
,
'view
s'
:
[[
self
.
env
.
ref
(
'ccs_base.view_batch_get_pod_info_wizard_form'
)
.
id
,
"form"
]]
,
'target'
:
'new'
,
'target'
:
'new'
,
}
}
...
@@ -1198,6 +1240,22 @@ class CcBL(models.Model):
...
@@ -1198,6 +1240,22 @@ class CcBL(models.Model):
}
}
def
action_batch_download_pod
(
self
):
"""
将选中的提单以提单号命名下载尾程交接POD文件,若文件有多个则以提单-1/-2进行命名下载,若选择多个提单,则将所有文件打包成zip,zip命名则以POD进行命名
"""
# 检查是否有选中的提单
if
not
self
:
raise
UserError
(
_
(
'Please select at least one bill of loading.'
))
# 检查是否有尾程交接POD文件
fix_name
=
'尾程交接POD(待大包数量和箱号)'
has_files
=
self
.
env
[
'cc.clearance.file'
]
.
search_count
([(
'bl_id'
,
'in'
,
self
.
ids
),
(
'file_name'
,
'='
,
fix_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
()
# 增加一个清关进度的业务对象,继承自models.Model, 用于管理业务数据.业务数据包括提单号、清关节点(业务对象)、进度日期、进度描述、更新人
# 增加一个清关进度的业务对象,继承自models.Model, 用于管理业务数据.业务数据包括提单号、清关节点(业务对象)、进度日期、进度描述、更新人
class
CcProgress
(
models
.
Model
):
class
CcProgress
(
models
.
Model
):
# 模型名称
# 模型名称
...
...
ccs_base/views/cc_bl_view.xml
浏览文件 @
91014d40
...
@@ -329,7 +329,7 @@
...
@@ -329,7 +329,7 @@
<field
name=
"res_model"
>
cc.bl
</field>
<field
name=
"res_model"
>
cc.bl
</field>
<field
name=
"view_mode"
>
tree,form,pivot,graph,calendar
</field>
<field
name=
"view_mode"
>
tree,form,pivot,graph,calendar
</field>
<field
name=
"domain"
>
[('bl_type','=','tk')]
</field>
<field
name=
"domain"
>
[('bl_type','=','tk')]
</field>
<field
name=
"context"
>
{'search_default_filter_state_not_finished':1}
</field>
<field
name=
"context"
>
{'search_default_filter_state_not_finished':1
,'default_bl_type':'tk'
}
</field>
<field
name=
"view_id"
ref=
"tree_cc_bl_view"
/>
<field
name=
"view_id"
ref=
"tree_cc_bl_view"
/>
<field
name=
"help"
type=
"html"
>
<field
name=
"help"
type=
"html"
>
<p>
<p>
...
@@ -337,52 +337,12 @@
...
@@ -337,52 +337,12 @@
</field>
</field>
</record>
</record>
<!--
<record model="ir.ui.view" id="tree_temu_cc_bl_view">
<field name="name">tree.temu.cc.bl</field>
<field name="model">cc.bl</field>
<field name="arch" type="xml">
<tree string="Temu Bill of Loading" decoration-warning="is_cancel==True" js_class="cc_temu_bl_tree">
<field optional="show" name="state" string="Status" widget="badge" decoration-info="state=='draft'"
decoration-primary="state=='ccing'" decoration-success="state=='done'"/>
<field optional="show" name="customs_clearance_status" string="Customs Clearance Status"/>
<field optional="show" name="bl_no" string="Bill of Loading No."/>
<field optional="show" name="bl_date" string="B/L Date"/>
<field optional="show" name="last_mile_provider_ids" string="Last Mile Providers"
widget="many2many_tags"/>
<field optional="hide" name="transfer_bl_no" string="Transfer Bill of Loading No."/>
<field optional="show" name="customer_id" string="Customer"/>
<field optional="show" name="customs_bl_no" string="Customs Bill of Loading No."/>
<field optional="hide" name="big_package_sell_country" string="Sell Country"/>
<field optional="hide" name="billing_weight" string="Billing Weight"/>
<field optional="hide" name="actual_weight" string="Actual Weight"/>
<field optional="hide" name="big_package_qty" string="Big Package"/>
<field optional="hide" name="bl_total_big_qty" string="Receive Big Package"/>
<field optional="hide" name="bl_ship_package_qty" string="Receive Ship Package"/>
<field optional="hide" name="bl_total_qty" string="Receive Goods Qty"/>
<field optional="show" name="bl_total_amount" string="Total Amount"/>
<field optional="show" name="cc_company_id" string="CC Company"/>
<field optional="show" name="cc_country_id" string="CC Country"/>
<field optional="show" name="cc_deadline" string="CC Deadline"/>
<field optional="show" name="trade_type" string="Trade Type"/>
<field optional="hide" name="transport_tool_code" string="Transport Tool Code"/>
<field optional="hide" name="transport_tool_name" string="Transport Tool Name"/>
<field optional="show" name="start_port_code" string="Start Port Code"/>
<field optional="show" name="eta" string="ETA"/>
<field optional="show" name="end_port_code" string="End Port Code"/>
<field optional="show" name="etd" string="ETD"/>
<field optional="show" name="is_cancel" string="Is Cancel"/>
<field optional="hide" name="cancel_reason" string="Cancel Reason"/>
<field optional="show" name="create_date"/>
</tree>
</field>
</record> -->
<record
model=
"ir.actions.act_window"
id=
"action_temu_bl"
>
<record
model=
"ir.actions.act_window"
id=
"action_temu_bl"
>
<field
name=
"name"
>
TEMU Bill of Loading
</field>
<field
name=
"name"
>
TEMU Bill of Loading
</field>
<field
name=
"res_model"
>
cc.bl
</field>
<field
name=
"res_model"
>
cc.bl
</field>
<field
name=
"view_mode"
>
tree,form,pivot,graph,calendar
</field>
<field
name=
"view_mode"
>
tree,form,pivot,graph,calendar
</field>
<field
name=
"domain"
>
[('bl_type','=','temu')]
</field>
<field
name=
"domain"
>
[('bl_type','=','temu')]
</field>
<field
name=
"context"
>
{'default_bl_type':'temu'}
</field>
<field
name=
"view_id"
ref=
"tree_cc_bl_view"
/>
<field
name=
"view_id"
ref=
"tree_cc_bl_view"
/>
<!-- <field name="view_id" ref="tree_temu_cc_bl_view"/> -->
<!-- <field name="view_id" ref="tree_temu_cc_bl_view"/> -->
<field
name=
"context"
>
{'search_default_filter_state_not_finished':1}
</field>
<field
name=
"context"
>
{'search_default_filter_state_not_finished':1}
</field>
...
@@ -468,9 +428,9 @@
...
@@ -468,9 +428,9 @@
</record>
</record>
<!--
批量创建temu提单
-->
<!--
下载POD
-->
<record
id=
"bl_create_temu_bl
_server_action"
model=
"ir.actions.server"
>
<record
id=
"bl_download_pod
_server_action"
model=
"ir.actions.server"
>
<field
name=
"name"
>
Batch
Create BL
</field>
<field
name=
"name"
>
Batch
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>
...
@@ -478,7 +438,7 @@
...
@@ -478,7 +438,7 @@
<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_
get_pod_info
()
action = records.action_batch_
download_pod
()
</field>
</field>
</record>
</record>
...
...
ccs_base/wizard/batch_get_pod_info_wizard.py
浏览文件 @
91014d40
差异被折叠。
点击展开。
ccs_base/wizard/batch_get_pod_info_wizard_views.xml
浏览文件 @
91014d40
...
@@ -131,7 +131,9 @@
...
@@ -131,7 +131,9 @@
<!-- 确认按钮:使用已处理的文件数据进行回写 -->
<!-- 确认按钮:使用已处理的文件数据进行回写 -->
<!-- 如果有失败的文件(show_error_message不为空),需要勾选generate_successful_processed才显示;如果全部成功,直接显示 -->
<!-- 如果有失败的文件(show_error_message不为空),需要勾选generate_successful_processed才显示;如果全部成功,直接显示 -->
<button
string=
"Confirm"
type=
"object"
name=
"confirm"
class=
"btn-primary"
<button
string=
"Confirm"
type=
"object"
name=
"confirm"
class=
"btn-primary"
attrs=
"{'invisible': ['|', ('get_last_mile_pod','=',True), '|', '|', ('pdf_file', '=', False), ('show_error_message', '!=', False), ('generate_successful_processed', '=', False)]}"
/>
attrs=
"{'invisible': [('get_last_mile_pod','=',True)]}"
/>
<button
string=
"Confirm"
type=
"object"
name=
"confirm"
class=
"btn-primary"
attrs=
"{'invisible': ['|', ('pdf_file', '=', False), '&', ('show_error_message', '!=', False), ('generate_successful_processed', '=', False)]}"
/>
<button
string=
"Close"
special=
"cancel"
/>
<button
string=
"Close"
special=
"cancel"
/>
</footer>
</footer>
</sheet>
</sheet>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论