Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
847e9d52
提交
847e9d52
authored
8月 27, 2024
作者:
贺阳
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加导出的向导
上级
37bf0f2d
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
811 行增加
和
34 行删除
+811
-34
__init__.py
ccs_base/controllers/__init__.py
+2
-0
export_bl_and_package_xlsx.py
ccs_base/controllers/export_bl_and_package_xlsx.py
+694
-0
ir.model.access.csv
ccs_base/security/ir.model.access.csv
+1
-0
cc_bl_view.xml
ccs_base/views/cc_bl_view.xml
+48
-33
__init__.py
ccs_base/wizard/__init__.py
+1
-1
export_bl_big_package_xlsx_wizard.py
ccs_base/wizard/export_bl_big_package_xlsx_wizard.py
+65
-0
没有找到文件。
ccs_base/controllers/__init__.py
0 → 100644
浏览文件 @
847e9d52
from
.
import
export_bl_and_package_xlsx
ccs_base/controllers/export_bl_and_package_xlsx.py
0 → 100644
浏览文件 @
847e9d52
# -*- coding: utf-8 -*-
import
base64
import
copy
import
io
import
json
import
zipfile
import
xlwt
import
xlsxwriter
from
.util
import
check_pdd_code
from
odoo
import
http
from
odoo.http
import
request
import
logging
from
datetime
import
timedelta
_logger
=
logging
.
getLogger
(
__name__
)
class
ExportBlAndPackageXlsx
(
http
.
Controller
):
# 公共导出包裹信息方法
def
common_package_data
(
self
,
big_bag_objs
):
worksheet
=
xlwt
.
Workbook
(
encoding
=
'utf-8'
)
sheet1
=
worksheet
.
add_sheet
(
'包裹数据'
,
cell_overwrite_ok
=
True
)
font_style
=
xlwt
.
easyxf
(
'font: height 220,name Arial,bold on; align: wrap on, vert centre, horiz center;'
)
index
=
0
for
i
in
range
(
13
):
sheet1
.
col
(
i
)
.
width
=
400
*
11
sheet1
.
col
(
12
)
.
width
=
600
*
11
sheet1
.
write
(
index
,
0
,
u'TRACKING NO.'
,
font_style
)
sheet1
.
write
(
index
,
1
,
u'CUSTOMER REF'
,
font_style
)
sheet1
.
write
(
index
,
2
,
u'Internal Account Number'
,
font_style
)
sheet1
.
write
(
index
,
3
,
u'SENDER NAME'
,
font_style
)
sheet1
.
write
(
index
,
4
,
u'SHIPPER ADD 1'
,
font_style
)
sheet1
.
write
(
index
,
5
,
u'SHIPPER ADD 2'
,
font_style
)
sheet1
.
write
(
index
,
6
,
u'SHIPPER ADD 3'
,
font_style
)
sheet1
.
write
(
index
,
7
,
u'SENDER CITY'
,
font_style
)
sheet1
.
write
(
index
,
8
,
u'Ship State'
,
font_style
)
sheet1
.
write
(
index
,
9
,
u'SENDER POSTCODE'
,
font_style
)
sheet1
.
write
(
index
,
10
,
u'SENDER COUNTRY'
,
font_style
)
sheet1
.
write
(
index
,
11
,
u'RECEIPIENT NAME'
,
font_style
)
sheet1
.
write
(
index
,
12
,
u'RECEIPIENT ADD 1'
,
font_style
)
sheet1
.
write
(
index
,
13
,
u'RECEIPIENT ADD 2'
,
font_style
)
sheet1
.
write
(
index
,
14
,
u'RECEIPIENT ADD 3'
,
font_style
)
sheet1
.
write
(
index
,
15
,
u'RECEIPIENT CITY'
,
font_style
)
sheet1
.
write
(
index
,
16
,
u'RECEIPIENT COUNTY'
,
font_style
)
sheet1
.
write
(
index
,
17
,
u'RECEIPIENT POSTCODE'
,
font_style
)
sheet1
.
write
(
index
,
18
,
u'RECEPIENT EMAIL'
,
font_style
)
sheet1
.
write
(
index
,
19
,
u'PHONE NUMBER'
,
font_style
)
sheet1
.
write
(
index
,
20
,
u'GROSS WEIGHT (KG)'
,
font_style
)
sheet1
.
write
(
index
,
21
,
u'NET WEIGHT (KG)'
,
font_style
)
sheet1
.
write
(
index
,
22
,
u'Currency'
,
font_style
)
sheet1
.
write
(
index
,
23
,
u'SKU NUMBER'
,
font_style
)
sheet1
.
write
(
index
,
24
,
u'ITEM DESCRIPTION'
,
font_style
)
sheet1
.
write
(
index
,
25
,
u'ITEM HS CODE'
,
font_style
)
sheet1
.
write
(
index
,
26
,
u'ITEM QUANTITY'
,
font_style
)
sheet1
.
write
(
index
,
27
,
u'UNIT VALUE'
,
font_style
)
sheet1
.
write
(
index
,
28
,
u'TOTAL VALUE'
,
font_style
)
sheet1
.
write
(
index
,
29
,
u'VAT'
,
font_style
)
sheet1
.
write
(
index
,
30
,
u'ONLINE SELLING PLACE'
,
font_style
)
sheet1
.
write
(
index
,
31
,
u'PRODUCT LINK'
,
font_style
)
sheet1
.
write
(
index
,
32
,
u'LENGTH'
,
font_style
)
sheet1
.
write
(
index
,
33
,
u'WIDTH'
,
font_style
)
sheet1
.
write
(
index
,
34
,
u'HEIGHT'
,
font_style
)
ship_package_obj
=
big_bag_objs
.
mapped
(
'ship_package_ids'
)
good_index
=
0
num
=
0
parcel_export_num
=
request
.
env
[
"ir.config_parameter"
]
.
sudo
()
.
get_param
(
'parcel_export_num'
)
or
50000
for
parcel_idx
,
parcel_item
in
enumerate
(
ship_package_obj
):
# 收件人名称
receive_name
=
''
# 收货人地址街道
receive_address_street
=
''
# 收货人地址市
receive_address_market
=
''
# 收货人地址州
receive_address_state
=
''
# 收货人国家
receive_address_country
=
''
# 收货人电话
receive_address_phone
=
''
# 主单号
order_no
=
parcel_item
.
big_bag_id
.
order_id
.
master_business_no
or
''
# 大包裹号
big_bag_no
=
parcel_item
.
big_bag_id
.
big_bag_no
or
''
# 大包重量
big_bag_weight
=
parcel_item
.
big_bag_id
.
big_bag_weight
or
''
# 订单号
provider_order_no
=
parcel_item
.
provider_order_no
or
''
# 运单号
tracking_no
=
parcel_item
.
tracking_no
or
''
if
parcel_item
.
shipping_info
:
shipping_info_data
=
json
.
loads
(
parcel_item
.
shipping_info
)
receive_name
=
shipping_info_data
[
'first_name'
]
if
shipping_info_data
.
get
(
'first_name'
)
else
''
receive_address_street
=
shipping_info_data
[
'address'
][
'address_l3'
]
if
shipping_info_data
.
get
(
'address'
,
{})
.
get
(
'address_l3'
)
else
''
receive_address_market
=
shipping_info_data
[
'address'
][
'address_l2'
]
if
shipping_info_data
.
get
(
'address'
,
{})
.
get
(
'address_l2'
)
else
''
receive_address_state
=
shipping_info_data
[
'address'
][
'address_l1'
]
if
shipping_info_data
.
get
(
'address'
,
{})
.
get
(
'address_l1'
)
else
''
receive_address_country
=
shipping_info_data
[
'address'
][
'address_l0'
]
if
shipping_info_data
.
get
(
'address'
,
{})
.
get
(
'address_l0'
)
else
''
receive_address_phone
=
shipping_info_data
[
'phone'
]
if
shipping_info_data
.
get
(
'phone'
)
else
''
if
parcel_item
.
goods_ids
:
for
good_item
in
parcel_item
.
goods_ids
:
good_index
+=
1
# 商品中文名称
product_name_cn
=
good_item
[
'product_name_cn'
]
if
good_item
.
get
(
'product_name_cn'
)
else
''
# hs编码
hscode
=
good_item
[
'hscode'
]
if
good_item
.
get
(
'hscode'
)
else
''
# 商品数量
qty
=
good_item
[
'qty'
]
if
good_item
.
get
(
'qty'
)
else
''
# 总价
unit_price
=
good_item
[
'unit_price'
]
if
good_item
.
get
(
'unit_price'
)
else
''
# 币制
unit_code
=
good_item
[
'unit_code'
]
if
good_item
.
get
(
'unit_code'
)
else
''
# 总毛重
unit_weight
=
good_item
[
'unit_weight'
]
if
good_item
.
get
(
'unit_weight'
)
else
''
sheet1
.
write
(
good_index
,
0
,
order_no
)
sheet1
.
write
(
good_index
,
1
,
big_bag_no
)
sheet1
.
write
(
good_index
,
2
,
big_bag_weight
)
sheet1
.
write
(
good_index
,
3
,
provider_order_no
)
sheet1
.
write
(
good_index
,
4
,
tracking_no
)
sheet1
.
write
(
good_index
,
5
,
receive_address_country
)
sheet1
.
write
(
good_index
,
6
,
product_name_cn
)
sheet1
.
write
(
good_index
,
7
,
hscode
)
sheet1
.
write
(
good_index
,
8
,
qty
)
sheet1
.
write
(
good_index
,
9
,
unit_price
)
sheet1
.
write
(
good_index
,
10
,
unit_code
)
sheet1
.
write
(
good_index
,
11
,
unit_weight
)
sheet1
.
write
(
good_index
,
12
,
'TikTok'
)
if
good_index
==
int
(
parcel_export_num
):
num
+=
1
sheet1
=
worksheet
.
add_sheet
(
'包裹数据(
%
s)'
%
num
,
cell_overwrite_ok
=
True
)
for
i
in
range
(
13
):
sheet1
.
col
(
i
)
.
width
=
400
*
11
sheet1
.
col
(
12
)
.
width
=
600
*
11
sheet1
.
write
(
index
,
0
,
u'主单号'
,
font_style
)
sheet1
.
write
(
index
,
1
,
u'大包裹号'
,
font_style
)
sheet1
.
write
(
index
,
2
,
u'大包重量'
,
font_style
)
sheet1
.
write
(
index
,
3
,
u'订单号'
,
font_style
)
sheet1
.
write
(
index
,
4
,
u'运单号'
,
font_style
)
sheet1
.
write
(
index
,
5
,
u'收货人国家'
,
font_style
)
sheet1
.
write
(
index
,
6
,
u'商品中文名称'
,
font_style
)
sheet1
.
write
(
index
,
7
,
u'hs编码'
,
font_style
)
sheet1
.
write
(
index
,
8
,
u'商品数量'
,
font_style
)
sheet1
.
write
(
index
,
9
,
u'总价'
,
font_style
)
sheet1
.
write
(
index
,
10
,
u'币制'
,
font_style
)
sheet1
.
write
(
index
,
11
,
u'总毛重'
,
font_style
)
sheet1
.
write
(
index
,
12
,
u'电商平台/海外仓地址'
,
font_style
)
good_index
=
0
return
worksheet
# 运单导出包裹清关数据 每个运单导出一个文件 生成压缩包
@http.route
([
'/export/flight_package/xls/<string:arr>/<string:select_type>'
],
type
=
'http'
,
auth
=
"public"
)
def
export_flight_package_xls
(
self
,
arr
,
select_type
):
arr
=
json
.
loads
(
arr
)
flight_objs
=
http
.
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
search
([(
'id'
,
'in'
,
arr
)],
order
=
'id'
)
zip_buffer
=
io
.
BytesIO
()
with
zipfile
.
ZipFile
(
zip_buffer
,
'w'
,
zipfile
.
ZIP_DEFLATED
)
as
zip_file
:
for
flight
in
flight_objs
:
big_bag_objs
=
flight
.
big_package_ids
worksheet
=
self
.
common_package_data
(
big_bag_objs
)
# 将Excel保存到内存中的文件对象
excel_file
=
io
.
BytesIO
()
worksheet
.
save
(
excel_file
)
excel_file
.
seek
(
0
)
zip_file
.
writestr
(
f
"{flight.master_business_no}.xls"
,
excel_file
.
read
())
# 压缩
zip_buffer
.
seek
(
0
)
headers
=
[
(
'Content-Type'
,
'application/x-zip-compressed'
),
(
'Content-Disposition'
,
'attachment; filename="parcel_data.zip"'
),
]
response
=
http
.
request
.
make_response
(
zip_buffer
.
getvalue
(),
headers
=
headers
)
return
response
# 导出包裹清关数据
@http.route
([
'/export/big_package/xls/<string:arr>/<string:model_name>'
],
type
=
'http'
,
auth
=
"public"
)
def
export_big_package_xls
(
self
,
arr
,
model_name
):
arr
=
json
.
loads
(
arr
)
if
model_name
==
'ao.big.package'
:
big_bag_objs
=
http
.
request
.
env
[
'ao.big.package'
]
.
sudo
()
.
search
([(
'id'
,
'in'
,
arr
)],
order
=
'order_id'
)
else
:
big_bag_objs
=
http
.
request
.
env
[
'ao.big.package'
]
.
sudo
()
.
search
([(
'order_id'
,
'in'
,
arr
)],
order
=
'order_id'
)
# print(model_name, len(big_bag_objs), big_bag_objs)
worksheet
=
self
.
common_package_data
(
big_bag_objs
)
response
=
http
.
request
.
make_response
(
None
,
headers
=
[(
'Content-Type'
,
'application/vnd.ms-excel'
),
(
'Content-Disposition'
,
u'attachment; filename=parcel_data.xls;'
)])
worksheet
.
save
(
response
.
stream
)
return
response
# 客户中心我的订舱导出订舱数据
@http.route
([
'/export/customer_order/xls/<string:arr>'
],
type
=
'http'
,
auth
=
"public"
)
def
export_customer_order_xls
(
self
,
arr
):
arr
=
json
.
loads
(
arr
)
order_objs
=
http
.
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
search
([(
'id'
,
'in'
,
arr
)])
worksheet
=
xlwt
.
Workbook
(
encoding
=
'utf-8'
)
sheet1
=
worksheet
.
add_sheet
(
'订舱数据'
,
cell_overwrite_ok
=
True
)
font_style
=
xlwt
.
easyxf
(
'font: height 220,name 微软雅黑,bold on; align: wrap on, vert centre, horiz center;'
)
index
=
0
sheet1
.
col
(
0
)
.
width
=
400
*
11
sheet1
.
col
(
8
)
.
width
=
300
*
11
sheet1
.
col
(
10
)
.
width
=
350
*
11
sheet1
.
col
(
11
)
.
width
=
350
*
11
sheet1
.
write
(
index
,
0
,
u'运单号'
,
font_style
)
sheet1
.
write
(
index
,
1
,
u'订舱数量'
,
font_style
)
sheet1
.
write
(
index
,
2
,
u'订舱重量'
,
font_style
)
sheet1
.
write
(
index
,
3
,
u'订舱体积'
,
font_style
)
sheet1
.
write
(
index
,
4
,
u'航班'
,
font_style
)
sheet1
.
write
(
index
,
5
,
u'航次'
,
font_style
)
sheet1
.
write
(
index
,
6
,
u'始发港'
,
font_style
)
sheet1
.
write
(
index
,
7
,
u'目的港'
,
font_style
)
sheet1
.
write
(
index
,
8
,
u'最终目的地'
,
font_style
)
sheet1
.
write
(
index
,
9
,
u'是否包板'
,
font_style
)
# sheet1.write(index, 10, u'空运单价', font_style)
# sheet1.write(index, 10, u'BSA价格', font_style)
sheet1
.
write
(
index
,
10
,
u'订舱日期'
,
font_style
)
sheet1
.
write
(
index
,
11
,
u'当前运单状态'
,
font_style
)
for
order_idx
,
order_item
in
enumerate
(
order_objs
):
order_idx
+=
1
sheet1
.
write
(
order_idx
,
0
,
order_item
.
master_business_no
)
sheet1
.
write
(
order_idx
,
1
,
order_item
.
order_number
)
sheet1
.
write
(
order_idx
,
2
,
order_item
.
order_weight
)
sheet1
.
write
(
order_idx
,
3
,
order_item
.
order_volume
)
sheet1
.
write
(
order_idx
,
4
,
order_item
.
voyage_id
.
voyage_name
or
''
)
sheet1
.
write
(
order_idx
,
5
,
order_item
.
voyage_name
or
''
)
sheet1
.
write
(
order_idx
,
6
,
order_item
.
depart_port_id
.
three_no
)
sheet1
.
write
(
order_idx
,
7
,
order_item
.
arrive_port_id
.
three_no
)
sheet1
.
write
(
order_idx
,
8
,
order_item
.
final_port
)
sheet1
.
write
(
order_idx
,
9
,
'是'
if
order_item
.
is_all
else
'否'
)
# sheet1.write(order_idx, 10, order_item.plane_price)
# sheet1.write(order_idx, 10, order_item.plane_all_amount)
order_date
=
''
if
order_item
.
track_ids
:
for
track
in
order_item
.
track_ids
:
if
track
.
description
==
'[已订舱]预报运单'
and
track
.
happend_time
:
dt
=
http
.
request
.
env
[
'ao.common'
]
.
sudo
()
.
get_add_time
(
track
.
happend_time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
))
order_date
=
dt
[
0
:
10
]
sheet1
.
write
(
order_idx
,
10
,
order_date
)
sheet1
.
write
(
order_idx
,
11
,
order_item
.
state
)
response
=
http
.
request
.
make_response
(
None
,
headers
=
[(
'Content-Type'
,
'application/vnd.ms-excel'
),
(
'Content-Disposition'
,
u'attachment; filename=customer_order.xls;'
)])
worksheet
.
save
(
response
.
stream
)
return
response
# 客户中心订舱单导出
@http.route
([
'/export/customer_book/xls/<string:arr>'
],
type
=
'http'
,
auth
=
"public"
)
def
export_customer_book_order_xls
(
self
,
arr
):
arr
=
json
.
loads
(
arr
)
order_objs
=
http
.
request
.
env
[
'ao.book.reservation'
]
.
sudo
()
.
search
([(
'id'
,
'in'
,
arr
)])
worksheet
=
xlwt
.
Workbook
(
encoding
=
'utf-8'
)
sheet1
=
worksheet
.
add_sheet
(
'订舱数据'
,
cell_overwrite_ok
=
True
)
font_style
=
xlwt
.
easyxf
(
'font: height 220,name 微软雅黑,bold on; align: wrap on, vert centre, horiz center;'
)
index
=
0
sheet1
.
col
(
0
)
.
width
=
400
*
11
sheet1
.
col
(
8
)
.
width
=
300
*
11
sheet1
.
col
(
10
)
.
width
=
350
*
11
sheet1
.
col
(
11
)
.
width
=
350
*
11
sheet1
.
write
(
index
,
0
,
'运单号'
,
font_style
)
sheet1
.
write
(
index
,
1
,
'订舱数量'
,
font_style
)
sheet1
.
write
(
index
,
2
,
'订舱重量'
,
font_style
)
sheet1
.
write
(
index
,
3
,
'订舱体积'
,
font_style
)
sheet1
.
write
(
index
,
4
,
'航班'
,
font_style
)
sheet1
.
write
(
index
,
5
,
'航次'
,
font_style
)
sheet1
.
write
(
index
,
6
,
'始发港'
,
font_style
)
sheet1
.
write
(
index
,
7
,
'目的港'
,
font_style
)
sheet1
.
write
(
index
,
8
,
'最终目的地'
,
font_style
)
sheet1
.
write
(
index
,
9
,
'是否包板'
,
font_style
)
sheet1
.
write
(
index
,
10
,
'订舱日期'
,
font_style
)
sheet1
.
write
(
index
,
11
,
'当前运单状态'
,
font_style
)
for
order_idx
,
order_item
in
enumerate
(
order_objs
):
order_idx
+=
1
sheet1
.
write
(
order_idx
,
0
,
order_item
.
master_business_no
)
sheet1
.
write
(
order_idx
,
1
,
order_item
.
order_number
)
sheet1
.
write
(
order_idx
,
2
,
order_item
.
order_weight
)
sheet1
.
write
(
order_idx
,
3
,
order_item
.
order_volume
)
sheet1
.
write
(
order_idx
,
4
,
order_item
.
voyage_id
.
voyage_name
or
''
)
sheet1
.
write
(
order_idx
,
5
,
order_item
.
voyage_id
.
name
or
''
)
sheet1
.
write
(
order_idx
,
6
,
order_item
.
voyage_id
.
depart_port_id
.
three_no
)
sheet1
.
write
(
order_idx
,
7
,
order_item
.
voyage_id
.
arrive_port_id
.
three_no
)
sheet1
.
write
(
order_idx
,
8
,
order_item
.
final_port
)
sheet1
.
write
(
order_idx
,
9
,
'是'
if
order_item
.
is_all
else
'否'
)
order_date
=
''
if
order_item
.
waybill_id
.
track_ids
:
for
track
in
order_item
.
track_ids
:
if
track
.
description
==
'[已订舱]预报运单'
and
track
.
happend_time
:
dt
=
http
.
request
.
env
[
'ao.common'
]
.
sudo
()
.
get_add_time
(
track
.
happend_time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
))
order_date
=
dt
[
0
:
10
]
sheet1
.
write
(
order_idx
,
10
,
order_date
)
sheet1
.
write
(
order_idx
,
11
,
order_item
.
master_waybill_id
.
state
or
''
)
response
=
http
.
request
.
make_response
(
None
,
headers
=
[(
'Content-Type'
,
'application/vnd.ms-excel'
),
(
'Content-Disposition'
,
u'attachment; filename=customer_order.xls;'
)])
worksheet
.
save
(
response
.
stream
)
return
response
# 运单轨迹导出
@http.route
([
'/export/order_track/xls/<string:arr>'
],
type
=
'http'
,
auth
=
"public"
)
def
export_order_track_xls
(
self
,
arr
):
arr
=
json
.
loads
(
arr
)
order_objs
=
http
.
request
.
env
[
'ao.book.reservation'
]
.
sudo
()
.
search
([(
'id'
,
'in'
,
arr
)])
worksheet
=
xlwt
.
Workbook
(
encoding
=
'utf-8'
)
sheet1
=
worksheet
.
add_sheet
(
'运单轨迹数据'
,
cell_overwrite_ok
=
True
)
font_style
=
xlwt
.
easyxf
(
'font: height 220,name 微软雅黑,bold on; align: wrap on, vert centre, horiz center;'
)
index
=
0
for
i
in
range
(
4
):
sheet1
.
col
(
i
)
.
width
=
400
*
11
for
i
in
range
(
4
,
8
):
sheet1
.
col
(
i
)
.
width
=
500
*
11
sheet1
.
col
(
2
)
.
width
=
700
*
11
sheet1
.
col
(
4
)
.
width
=
650
*
11
sheet1
.
write
(
index
,
0
,
'状态'
,
font_style
)
sheet1
.
write
(
index
,
1
,
'主单号'
,
font_style
)
sheet1
.
write
(
index
,
2
,
'订舱航班'
,
font_style
)
sheet1
.
write
(
index
,
3
,
'订舱航次号'
,
font_style
)
sheet1
.
write
(
index
,
4
,
'执飞航班/实际起飞时间'
,
font_style
)
sheet1
.
write
(
index
,
5
,
'运单轨迹/业务描述'
,
font_style
)
sheet1
.
write
(
index
,
6
,
'运单轨迹/地点'
,
font_style
)
sheet1
.
write
(
index
,
7
,
'运单轨迹/时间'
,
font_style
)
index
+=
1
for
order_idx
,
order_item
in
enumerate
(
order_objs
):
master_waybill_obj
=
order_item
.
master_waybill_id
if
master_waybill_obj
:
track_objs
=
master_waybill_obj
.
track_ids
sheet1
.
write
(
index
,
0
,
master_waybill_obj
.
state
)
sheet1
.
write
(
index
,
1
,
master_waybill_obj
.
master_business_no
)
sheet1
.
write
(
index
,
2
,
master_waybill_obj
.
voyage_id
.
name_get
()[
0
][
1
])
sheet1
.
write
(
index
,
3
,
master_waybill_obj
.
voyage_id
.
name
)
sheet1
.
write
(
index
,
4
,
(
master_waybill_obj
.
actual_voyage_id
.
actual_depart_time
+
timedelta
(
hours
=
8
))
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
if
master_waybill_obj
.
actual_voyage_id
.
actual_depart_time
else
''
)
for
i
,
track_obj
in
enumerate
(
track_objs
):
sheet1
.
write
(
index
,
5
,
track_obj
.
description
)
sheet1
.
write
(
index
,
6
,
track_obj
.
address
)
sheet1
.
write
(
index
,
7
,
track_obj
.
local_time
)
index
+=
1
# order_date = ''
# if order_item.waybill_id.track_ids:
# for track in order_item.track_ids:
# if track.description == '[已订舱]预报运单' and track.happend_time:
# dt = http.request.env['ao.common'].sudo().get_add_time(
# track.happend_time.strftime("%Y-%m-%d %H:%M:%S"))
# order_date = dt[0:10]
# sheet1.write(order_idx, 10, order_date)
# sheet1.write(order_idx, 11, order_item.master_waybill_id.state or '')
response
=
http
.
request
.
make_response
(
None
,
headers
=
[(
'Content-Type'
,
'application/vnd.ms-excel'
),
(
'Content-Disposition'
,
u'attachment; filename=order_track.xls;'
)])
worksheet
.
save
(
response
.
stream
)
return
response
class
PddTrack
(
http
.
Controller
):
@http.route
(
'/get/track'
,
type
=
'http'
,
auth
=
'public'
,
method
=
[
"POST"
,
"GET"
],
csrf
=
False
,
cors
=
"*"
)
@check_pdd_code
def
get_pdd_track
(
self
,
**
kw
):
res
=
{
'status'
:
'1'
,
'msg'
:
''
}
try
:
request
.
env
.
context
=
{
'lang'
:
'zh_CN'
}
redis_conn
=
request
.
env
[
'ao.common'
]
.
sudo
()
.
get_redis
()
if
kw
.
get
(
'parcel_no'
):
parcel_no
=
kw
.
get
(
'parcel_no'
)
parcel_no_rep
=
parcel_no
.
replace
(
' '
,
''
)
.
replace
(
'-'
,
''
)
.
replace
(
'/'
,
''
)
.
upper
()
if
res
[
'status'
]
==
'1'
:
sql
=
"select id,parcel_name from ao_parcel where UPPER(REPLACE(REPLACE(REPLACE(parcel_name, ' ', ''), '-', ''), '/', '')) = '{0}';"
.
format
(
parcel_no_rep
)
request
.
_cr
.
execute
(
sql
)
result
=
request
.
_cr
.
fetchall
()
if
result
:
select_parcel_no
=
result
[
0
][
1
]
if
kw
.
get
(
'order_no'
):
order_no_rep
=
kw
.
get
(
'order_no'
)
.
replace
(
' '
,
''
)
.
replace
(
'-'
,
''
)
.
replace
(
'/'
,
''
)
redis_parcel_arr
=
redis_conn
.
get
(
'parcel'
+
order_no_rep
)
if
redis_conn
!=
'no'
else
[]
# for order_parcel_a in order_parcel_arr:
if
redis_parcel_arr
:
if
select_parcel_no
not
in
redis_parcel_arr
:
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
res
[
'msg'
]
=
'包裹号
%
s不在提单
%
s内'
%
(
parcel_no
,
kw
.
get
(
'order_no'
))
else
:
exist_parcel_name
=
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
get_pdd_redis_order
(
kw
.
get
(
'order_no'
))
if
select_parcel_no
not
in
exist_parcel_name
:
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
res
[
'msg'
]
=
'包裹号
%
s不在提单
%
s内'
%
(
parcel_no
,
kw
.
get
(
'order_no'
))
flag
=
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
order_exist
(
kw
.
get
(
'order_no'
))
if
not
flag
:
res
[
'msg'
]
=
'找不到
%
s提单号'
%
kw
.
get
(
'order_no'
)
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
# 获取id
if
res
[
'status'
]
==
'1'
:
parcel_obj
=
request
.
env
[
'ao.parcel'
]
.
sudo
()
.
browse
(
result
[
0
][
0
])
redis_data
=
redis_conn
.
get
(
parcel_obj
.
order_id
.
master_business_no
.
replace
(
' '
,
''
)
.
replace
(
'-'
,
''
)
.
replace
(
'/'
,
''
))
if
redis_conn
!=
'no'
else
[]
if
redis_data
:
data
=
json
.
loads
(
redis_data
)
else
:
data
=
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
get_pdd_track
(
parcel_obj
.
order_id
.
id
)
if
data
[
'track_arr'
]:
data
[
'parcel_arr'
]
=
list
(
filter
(
lambda
x
:
x
in
[
select_parcel_no
],
data
[
'parcel_arr'
]))
res
[
'data'
]
=
data
else
:
res
[
'msg'
]
=
'该包裹号
%
s,暂未产生包裹轨迹'
%
parcel_no
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
else
:
res
[
'msg'
]
=
'找不到
%
s包裹号'
%
parcel_no
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
elif
kw
.
get
(
'order_no'
):
order_no
=
kw
.
get
(
'order_no'
)
order_no_rep
=
order_no
.
replace
(
' '
,
''
)
.
replace
(
'-'
,
''
)
.
replace
(
'/'
,
''
)
redis_data
=
redis_conn
.
get
(
order_no_rep
)
if
redis_conn
!=
'no'
else
[]
if
redis_data
:
data
=
json
.
loads
(
redis_data
)
if
data
[
'track_arr'
]:
res
[
'data'
]
=
data
else
:
res
[
'msg'
]
=
'该提单号
%
s,暂未产生包裹轨迹'
%
order_no
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
else
:
sql
=
"select id from ao_flight_order where REPLACE(REPLACE(REPLACE(master_business_no, ' ', ''), '-', ''), '/', '') = '{0}';"
.
format
(
order_no_rep
)
request
.
_cr
.
execute
(
sql
)
result
=
request
.
_cr
.
fetchall
()
if
result
:
# 获取id
data
=
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
get_pdd_track
(
result
[
0
][
0
])
if
data
[
'track_arr'
]:
res
[
'data'
]
=
data
else
:
res
[
'msg'
]
=
'该提单号
%
s,暂未产生包裹轨迹'
%
order_no
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
else
:
res
[
'msg'
]
=
'找不到
%
s提单号'
%
order_no
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
else
:
res
[
'msg'
]
=
'提单号和包裹号必传其一'
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
except
Exception
as
err
:
logging
.
error
(
'get_pdd_track: error
%
s'
%
str
(
err
))
res
[
'msg'
]
=
'系统错误,请联系开发人员!'
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
if
kw
.
get
(
'order_no'
)
and
kw
.
get
(
'parcel_no'
):
select_obj
=
'提单号/包裹号'
elif
kw
.
get
(
'order_no'
):
select_obj
=
'提单号'
elif
kw
.
get
(
'parcel_no'
):
select_obj
=
'包裹号'
else
:
select_obj
=
''
request
.
env
[
'ao.pdd.log'
]
.
create_pdd_log
(
select_obj
,
kw
.
get
(
'order_no'
)
if
kw
.
get
(
'order_no'
)
else
''
,
kw
.
get
(
'parcel_no'
)
if
kw
.
get
(
'parcel_no'
)
else
''
,
'/'
.
join
(
res
[
'data'
][
'parcel_arr'
])
if
res
[
'data'
]
else
''
,
False
if
res
[
'status'
]
==
"0"
else
True
,
res
[
'msg'
])
return
json
.
JSONEncoder
()
.
encode
(
res
)
@http.route
(
'/batch/get/track'
,
type
=
'http'
,
auth
=
'public'
,
method
=
[
"POST"
,
"GET"
],
csrf
=
False
,
cors
=
"*"
)
@check_pdd_code
def
batch_get_pdd_track
(
self
,
**
kw
):
res
=
{
'status'
:
'1'
,
'msg'
:
''
}
error_msg
=
[]
error_msg_parcel
=
[]
error_msg_order
=
[]
error_msg_no_track
=
[]
error_msg_no_parcel
=
[]
data
=
[]
correct_order_no
=
[]
correct_parcel_no
=
[]
parcel_no_dict
=
{}
for_correct_parcel_no
=
[]
try
:
request
.
env
.
context
=
{
'lang'
:
'zh_CN'
}
redis_conn
=
request
.
env
[
'ao.common'
]
.
sudo
()
.
get_redis
()
if
kw
.
get
(
'order_no_arr'
)
and
kw
.
get
(
'parcel_no_arr'
):
select_obj
=
'提单号/包裹号'
elif
kw
.
get
(
'order_no_arr'
):
select_obj
=
'提单号'
elif
kw
.
get
(
'parcel_no_arr'
):
select_obj
=
'包裹号'
else
:
select_obj
=
''
if
kw
.
get
(
'parcel_no_arr'
):
parcel_no_arr
=
json
.
loads
(
kw
.
get
(
'parcel_no_arr'
))
# 检查包裹是否存在
for
parcel_no
in
parcel_no_arr
:
flag
=
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
parcel_exist
(
parcel_no
)
if
not
flag
:
if
parcel_no
not
in
error_msg
:
error_msg
.
append
(
parcel_no
)
else
:
correct_parcel_no
.
append
(
flag
)
parcel_no_dict
[
flag
]
=
parcel_no
if
error_msg
:
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
res
[
'msg'
]
=
'
%
s找不到以上包裹号'
%
','
.
join
(
error_msg
)
# request.env['ao.pdd.log'].create_pdd_log(select_obj,
# kw.get('order_no_arr') if kw.get('order_no_arr') else '',
# kw.get('parcel_no_arr') if kw.get('parcel_no_arr') else '',
# '',
# False if res['status'] == "0" else True,
# res['msg'])
# return json.JSONEncoder().encode(res)
if
kw
.
get
(
'order_no_arr'
):
# 检查提单是否存在
order_no_arr
=
json
.
loads
(
kw
.
get
(
'order_no_arr'
))
for
order_no
in
order_no_arr
:
flag
=
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
order_exist
(
order_no
)
if
not
flag
:
if
order_no
not
in
error_msg_order
:
error_msg_order
.
append
(
order_no
)
else
:
correct_order_no
.
append
(
order_no
)
if
error_msg_order
:
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
if
not
error_msg
:
res
[
'msg'
]
+=
',
%
s找不到以上提单号'
%
','
.
join
(
error_msg_order
)
# return json.JSONEncoder().encode(res)
redis_order_data
=
[]
for
order_no
in
order_no_arr
:
redis_order_data
+=
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
get_pdd_redis_order
(
order_no
)
for
parcel_no
in
correct_parcel_no
:
if
parcel_no
not
in
redis_order_data
:
if
parcel_no_dict
.
get
(
parcel_no
)
not
in
error_msg_parcel
:
error_msg_parcel
.
append
(
parcel_no_dict
.
get
(
parcel_no
))
else
:
for_correct_parcel_no
.
append
(
parcel_no
)
correct_parcel_no
=
for_correct_parcel_no
if
error_msg_parcel
:
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
# if not res['msg']:
res
[
'msg'
]
+=
',
%
s以上包裹号不在提单内'
%
','
.
join
(
error_msg_parcel
)
# request.env['ao.pdd.log'].create_pdd_log(select_obj,
# kw.get('order_no_arr') if kw.get(
# 'order_no_arr') else '',
# kw.get('parcel_no_arr') if kw.get(
# 'parcel_no_arr') else '',
# '',
# False if res['status'] == "0" else True,
# res['msg'])
# return json.JSONEncoder().encode(res)
# for order_no in order_no_arr:
# track_data = request.env['ao.flight.order'].sudo().get_order_pdd_track(order_no)
# if track_data.get('parcel_arr'):
# # parcel_line_arr = []
# track_data['parcel_arr'] = list(filter(lambda x: x in parcel_no_arr, track_data['parcel_arr']))
# data.append(track_data)
# for order_no in for_correct_parcel_no:
# track_data = request.env['ao.flight.order'].sudo().get_order_pdd_track(order_no)
# if track_data.get('parcel_arr'):
# # parcel_line_arr = []
# track_data['parcel_arr'] = list(filter(lambda x: x in correct_parcel_no, track_data['parcel_arr']))
# data.append(track_data)
# res['data'] = data
# if res['data']:
# res['status'] = '1'
# write_parcel_arr = []
# for write_data in data:
# if write_data.get('parcel_arr'):
# write_parcel_arr += write_data['parcel_arr']
# request.env['ao.pdd.log'].create_pdd_log(select_obj,
# kw.get('order_no_arr') if kw.get('order_no_arr') else '',
# kw.get('parcel_no_arr') if kw.get('parcel_no_arr') else '',
# '/'.join(write_parcel_arr) if write_parcel_arr else '',
# False if res['status'] == "0" else True,
# res['msg'])
# return json.JSONEncoder().encode(res)
select_parcel_arr
=
[]
for
parcel_no
in
correct_parcel_no
:
select_parcel_arr
.
append
(
parcel_no
.
replace
(
' '
,
''
)
.
replace
(
'-'
,
''
)
.
replace
(
'/'
,
''
)
.
upper
())
select_parcel_str
=
'(
%
s)'
%
str
(
select_parcel_arr
)[
1
:
-
1
]
if
select_parcel_arr
:
sql
=
"select distinct(order_id),parcel_name from ao_parcel where UPPER(REPLACE(REPLACE(REPLACE(parcel_name, ' ', ''), '-', ''), '/', '')) in {0};"
.
format
(
select_parcel_str
)
request
.
_cr
.
execute
(
sql
)
result
=
request
.
_cr
.
fetchall
()
else
:
result
=
[]
# print(result)
exist_rest_arr
=
[]
if
result
:
for
rest
in
result
:
if
rest
[
0
]
not
in
exist_rest_arr
:
order_obj
=
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
browse
(
rest
[
0
])
exist_rest_arr
.
append
(
rest
[
0
])
track_data
=
order_obj
.
get_order_pdd_track
(
order_obj
.
master_business_no
)
if
track_data
.
get
(
'parcel_arr'
):
# parcel_line_arr = []
track_data
[
'parcel_arr'
]
=
list
(
filter
(
lambda
x
:
x
in
correct_parcel_no
,
track_data
[
'parcel_arr'
]))
if
track_data
.
get
(
'track_arr'
):
data
.
append
(
track_data
)
else
:
error_msg_no_track
.
append
(
order_obj
.
master_business_no
)
res
[
'msg'
]
+=
'提单号
%
s,包裹号
%
s,暂未产生包裹轨迹,'
%
(
order_obj
.
master_business_no
,
parcel_no_dict
[
rest
[
1
]])
# if error_msg_no_track:
# res['data'] = ''
# res['status'] = '0'
# res['msg'] += '%s以上提单暂未产生轨迹' % ','.join(error_msg_no_track)
res
[
'data'
]
=
data
if
res
[
'data'
]:
res
[
'status'
]
=
'1'
write_parcel_arr
=
[]
for
write_data
in
data
:
if
write_data
.
get
(
'parcel_arr'
):
write_parcel_arr
+=
write_data
[
'parcel_arr'
]
request
.
env
[
'ao.pdd.log'
]
.
create_pdd_log
(
select_obj
,
kw
.
get
(
'order_no_arr'
)
if
kw
.
get
(
'order_no_arr'
)
else
''
,
kw
.
get
(
'parcel_no_arr'
)
if
kw
.
get
(
'parcel_no_arr'
)
else
''
,
'/'
.
join
(
write_parcel_arr
)
if
write_parcel_arr
else
''
,
False
if
res
[
'status'
]
==
"0"
else
True
,
res
[
'msg'
])
return
json
.
JSONEncoder
()
.
encode
(
res
)
else
:
res
[
'data'
]
=
[]
elif
kw
.
get
(
'order_no_arr'
):
order_no_arr
=
json
.
loads
(
kw
.
get
(
'order_no_arr'
))
for
order_no
in
order_no_arr
:
flag
=
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
order_exist
(
order_no
)
if
not
flag
:
error_msg
.
append
(
order_no
)
else
:
correct_order_no
.
append
(
order_no
)
if
error_msg
:
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
res
[
'msg'
]
=
'
%
s找不到以上提单号'
%
','
.
join
(
error_msg
)
# request.env['ao.pdd.log'].create_pdd_log(select_obj,
# kw.get('order_no_arr') if kw.get('order_no_arr') else '',
# kw.get('parcel_no_arr') if kw.get('parcel_no_arr') else '',
# '',
# False if res['status'] == "0" else True,
# res['msg'])
# return json.JSONEncoder().encode(res)
for
order_no
in
correct_order_no
:
track_data
=
request
.
env
[
'ao.flight.order'
]
.
sudo
()
.
get_order_pdd_track
(
order_no
)
if
not
track_data
.
get
(
'parcel_arr'
):
error_msg_no_parcel
.
append
(
order_no
)
else
:
if
track_data
.
get
(
'track_arr'
):
data
.
append
(
track_data
)
else
:
error_msg_no_track
.
append
(
order_no
)
if
error_msg_no_parcel
:
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
res
[
'msg'
]
+=
'
%
s以上提单没有包裹信息'
%
','
.
join
(
error_msg_no_parcel
)
if
error_msg_no_track
:
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
res
[
'msg'
]
+=
'
%
s以上提单暂未产生轨迹'
%
','
.
join
(
error_msg_no_track
)
res
[
'data'
]
=
data
if
res
[
'data'
]:
res
[
'status'
]
=
'1'
write_parcel_arr
=
[]
for
write_data
in
data
:
if
write_data
.
get
(
'parcel_arr'
):
write_parcel_arr
+=
write_data
[
'parcel_arr'
]
request
.
env
[
'ao.pdd.log'
]
.
create_pdd_log
(
select_obj
,
kw
.
get
(
'order_no_arr'
)
if
kw
.
get
(
'order_no_arr'
)
else
''
,
kw
.
get
(
'parcel_no_arr'
)
if
kw
.
get
(
'parcel_no_arr'
)
else
''
,
'/'
.
join
(
write_parcel_arr
)
if
write_parcel_arr
else
''
,
False
if
res
[
'status'
]
==
"0"
else
True
,
res
[
'msg'
])
return
json
.
JSONEncoder
()
.
encode
(
res
)
else
:
res
[
'msg'
]
=
'提单号和包裹号必传其一'
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
except
Exception
as
err
:
logging
.
error
(
'batch_get_pdd_track: error
%
s'
%
str
(
err
))
res
[
'msg'
]
=
'系统错误,请联系开发人员!'
res
[
'data'
]
=
''
res
[
'status'
]
=
'0'
request
.
env
[
'ao.pdd.log'
]
.
create_pdd_log
(
select_obj
,
kw
.
get
(
'order_no_arr'
)
if
kw
.
get
(
'order_no_arr'
)
else
''
,
kw
.
get
(
'parcel_no_arr'
)
if
kw
.
get
(
'parcel_no_arr'
)
else
''
,
res
[
'data'
],
False
if
res
[
'status'
]
==
"0"
else
True
,
res
[
'msg'
])
return
json
.
JSONEncoder
()
.
encode
(
res
)
ccs_base/security/ir.model.access.csv
浏览文件 @
847e9d52
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
batch_input_ship_package_status_wizard_group_user,batch_input_ship_package_status_wizard_group_user,ccs_base.model_batch_input_ship_package_status_wizard,base.group_user,1,1,1,1
export_bl_big_package_xlsx_wizard_group_user,export_bl_big_package_xlsx_wizard_group_user,ccs_base.model_export_bl_big_package_xlsx_wizard,base.group_user,1,1,1,1
...
...
ccs_base/views/cc_bl_view.xml
浏览文件 @
847e9d52
...
...
@@ -7,7 +7,7 @@
<field
name=
"name"
>
tree.cc.bl
</field>
<field
name=
"model"
>
cc.bl
</field>
<field
name=
"arch"
type=
"xml"
>
<tree
string=
"Bill of Loading"
decoration-warning=
"is_cancel==True"
>
<tree
string=
"Bill of Loading"
decoration-warning=
"is_cancel==True"
>
<field
optional=
"show"
name=
"state"
string=
"Status"
/>
<field
optional=
"show"
name=
"bl_no"
string=
"Bill of Loading No."
/>
<field
optional=
"show"
name=
"bl_date"
string=
"B/L Date"
/>
...
...
@@ -24,8 +24,8 @@
<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="cc_progress_date" string="Current CC Progress Date"/>-->
<!-- <field optional="show" name="cc_progress" string="Current CC Progress"/>-->
<!-- <field optional="show" name="cc_progress_date" string="Current CC Progress Date"/>-->
<!-- <field optional="show" name="cc_progress" string="Current CC Progress"/>-->
<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"
/>
...
...
@@ -45,8 +45,9 @@
<field
name=
"arch"
type=
"xml"
>
<form
string=
"Bill of Loading"
>
<header>
<!-- # 为action_batch_input_ship_package_wizard添加一个按钮, 上下文中添加bl_id-->
<button
name=
"%(action_batch_input_ship_package_wizard)d"
type=
"action"
class=
"oe_highlight"
string=
"Update Ship Package Status"
context=
"{'default_bl_id': active_id}"
/>
<!-- # 为action_batch_input_ship_package_wizard添加一个按钮, 上下文中添加bl_id-->
<button
name=
"%(action_batch_input_ship_package_wizard)d"
type=
"action"
class=
"oe_highlight"
string=
"Update Ship Package Status"
context=
"{'default_bl_id': active_id}"
/>
<field
name=
"state"
widget=
"statusbar"
options=
"{'clickable': '1'}"
/>
</header>
...
...
@@ -54,28 +55,29 @@
<div
class=
"oe_button_box"
name=
"button_box"
>
<button
name=
"action_show_big_package"
type=
"object"
class=
"oe_stat_button"
icon=
"fa-cube"
>
class=
"oe_stat_button"
icon=
"fa-cube"
>
<div
class=
"o_stat_info"
>
<field
name=
"bl_total_big_qty"
class=
"o_stat_value"
/>
<span
class=
"o_stat_text"
>
Big Packages
</span>
</div>
</button>
<button
name=
"action_show_ship_package"
type=
"object"
class=
"oe_stat_button"
icon=
"fa-box"
>
<button
name=
"action_show_ship_package"
type=
"object"
class=
"oe_stat_button"
icon=
"fa-box"
>
<div
class=
"o_stat_info"
>
<field
name=
"bl_ship_package_qty"
class=
"o_stat_value"
/>
<span
class=
"o_stat_text"
>
Ship Packages
</span>
</div>
</button>
<button
name=
"action_show_package_good"
type=
"object"
class=
"oe_stat_button"
icon=
"fa-star"
>
<button
name=
"action_show_package_good"
type=
"object"
class=
"oe_stat_button"
icon=
"fa-star"
>
<div
class=
"o_stat_info"
>
<field
name=
"bl_total_qty"
class=
"o_stat_value"
/>
<span
class=
"o_stat_text"
>
Goods
</span>
</div>
</button>
</div>
<widget
name=
"web_ribbon"
bg_color=
"bg-warning"
title=
"Cancelled"
attrs=
"{'invisible': [('is_cancel', '=', False)]}"
/>
<widget
name=
"web_ribbon"
bg_color=
"bg-warning"
title=
"Cancelled"
attrs=
"{'invisible': [('is_cancel', '=', False)]}"
/>
<label
for=
"bl_no"
/>
<h1>
...
...
@@ -106,27 +108,29 @@
<field
name=
"bl_total_qty"
string=
"Receive Goods Qty"
/>
<field
name=
"bl_total_amount"
string=
"Total Amount"
/>
<separator/>
<field
name=
"cc_company_id"
string=
"CC Company"
requied=
"1"
domain=
"[('is_clearance_company', '=', True)]"
/>
<field
name=
"cc_company_id"
string=
"CC Company"
requied=
"1"
domain=
"[('is_clearance_company', '=', True)]"
/>
<field
name=
"cc_country_id"
string=
"CC Country"
requied=
"1"
/>
<field
name=
"cc_deadline"
string=
"CC Deadline"
/>
<!-- <field name="cc_progress_date" string="Current CC Progress Date"/>-->
<!-- <field name="cc_progress" string="Current CC Progress"/>-->
<!-- <field name="cc_progress_date" string="Current CC Progress Date"/>-->
<!-- <field name="cc_progress" string="Current CC Progress"/>-->
</group>
</group>
<notebook>
<!-- <page string="CC Progress">-->
<!-- <field name="cc_progress_ids" string="CC Progress"/>-->
<!-- </page>-->
<!-- <page string="Ship Packages">-->
<!-- <field name="ship_package_ids" string="Ship Packages"/>-->
<!-- </page>-->
<!-- <page string="Big Packages">-->
<!-- <field name="big_package_ids" string="Big Packages"/>-->
<!-- </page>-->
<!-- <page string="CC Progress">-->
<!-- <field name="cc_progress_ids" string="CC Progress"/>-->
<!-- </page>-->
<!-- <page string="Ship Packages">-->
<!-- <field name="ship_package_ids" string="Ship Packages"/>-->
<!-- </page>-->
<!-- <page string="Big Packages">-->
<!-- <field name="big_package_ids" string="Big Packages"/>-->
<!-- </page>-->
<page
string=
"Attachments"
>
<group>
<field
name=
"bl_attachment_ids"
string=
"B/L Attachments"
widget=
"many2many_binary"
readonly=
"1"
/>
<field
name=
"cc_attachment_ids"
string=
"CC Attachments"
/>
<field
name=
"bl_attachment_ids"
string=
"B/L Attachments"
widget=
"many2many_binary"
readonly=
"1"
/>
<field
name=
"cc_attachment_ids"
string=
"CC Attachments"
/>
</group>
</page>
<page
string=
"Other"
>
...
...
@@ -139,20 +143,21 @@
</notebook>
</sheet>
<div
class=
"oe_chatter"
>
<field
name=
"message_follower_ids"
/>
<field
name=
"activity_ids"
/>
<field
name=
"message_ids"
options=
"{'post_refresh': 'recipients'}"
/>
</div>
<field
name=
"message_follower_ids"
/>
<field
name=
"activity_ids"
/>
<field
name=
"message_ids"
options=
"{'post_refresh': 'recipients'}"
/>
</div>
</form>
</field>
</record>
<!-- # 定义日历视图 calendar, 日期采用cc_deadline, 显示提单号、客户、CC公司、CC国家、CC进度、状态-->
<!-- # 定义日历视图 calendar, 日期采用cc_deadline, 显示提单号、客户、CC公司、CC国家、CC进度、状态-->
<record
model=
"ir.ui.view"
id=
"calendar_cc_bl_view"
>
<field
name=
"name"
>
calendar.cc.bl
</field>
<field
name=
"model"
>
cc.bl
</field>
<field
name=
"arch"
type=
"xml"
>
<calendar
string=
"Bill of Loading"
date_start=
"cc_deadline"
date_stop=
"cc_deadline"
color=
"state"
mode=
"month"
>
<calendar
string=
"Bill of Loading"
date_start=
"cc_deadline"
date_stop=
"cc_deadline"
color=
"state"
mode=
"month"
>
<field
name=
"bl_no"
/>
<field
name=
"customer_id"
/>
<field
name=
"cc_company_id"
/>
...
...
@@ -201,7 +206,7 @@
<separator/>
<filter
name=
"filter_is_cancel"
string=
"Is Cancelled"
domain=
"[('is_cancel', '=', True)]"
/>
<filter
name=
"filter_not_cancel"
string=
"Not Show Cancelled"
domain=
"[('is_cancel','=',False)]"
/>
<filter
name=
"filter_not_cancel"
string=
"Not Show Cancelled"
domain=
"[('is_cancel','=',False)]"
/>
<separator/>
<filter
name=
"filter_bl_date"
string=
"B/L Date"
date=
"bl_date"
/>
<!-- # 增加一个过滤器, 用于显示今天到期的单据-->
...
...
@@ -315,6 +320,15 @@
<!-- </record>-->
<!-- <menuitem sequence="10" name="Bill of Loading" id="menu_cc_bl" action="action_cc_bl" web_icon="ccs_base,static/description/icon3.png"/>-->
<record
id=
"export_order_big_package_xls_server"
model=
"ir.actions.server"
>
<field
name=
"name"
>
导出报关数据
</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=
"code"
>
if records:
action = records.export_order_big_package_xls_action()
</field>
</record>
</odoo>
\ No newline at end of file
ccs_base/wizard/__init__.py
浏览文件 @
847e9d52
# -*- coding: utf-8 -*-
from
.
import
batch_input_ship_package_statu_wizard
# from . import push_result
from
.
import
export_bl_big_package_xlsx_wizard
# from . import again_push_wizard
# from . import parcel_exception_wizard
# from . import big_bag_pickup_wizard
...
...
ccs_base/wizard/export_bl_big_package_xlsx_wizard.py
0 → 100644
浏览文件 @
847e9d52
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from
odoo
import
models
,
api
,
fields
from
odoo.exceptions
import
Warning
,
ValidationError
class
ExportBlBigPackageXlsxWizard
(
models
.
TransientModel
):
_name
=
'export.bl.big.package.xlsx.wizard'
_description
=
'导出报关文件'
# 增加选择类型字段, 按节点和按面单号(多条)
select_type
=
fields
.
Selection
([
(
'yes'
,
'YES'
),
(
'no'
,
'NO'
)
],
string
=
'Whether to export in Big packages'
)
# 批量更新小包状态
def
submit
(
self
):
# 确认数据
if
not
self
.
is_ok
:
raise
ValidationError
(
'请确认以上数据正确.'
)
parcels
=
self
.
get_process_package
()
if
not
parcels
:
raise
ValidationError
(
'没有找到要更新的小包.'
)
# 判断异常状态是否选择了异常原因
reason_obj
=
self
.
env
[
'cc.node.exception.reason'
]
.
search
([(
'code_id'
,
'='
,
self
.
update_status
.
id
)])
if
reason_obj
and
not
self
.
node_exception_reason_id
:
raise
ValidationError
(
'请选择异常原因!'
)
# 更新状态
parcels
.
write
(
{
'state'
:
self
.
update_status
.
id
,
'node_exception_reason_id'
:
self
.
node_exception_reason_id
.
id
,
'process_time'
:
self
.
process_time
,
'state_explain'
:
self
.
state_explain
,
'is_sync'
:
False
})
# 生成sns日志
# self.bl_id.message_post(body='%s更新为%s' % (self.current_status.name or '', self.update_status.name or ''))
# 跳转显示本次更新状态的小包
return
{
'name'
:
'更新小包状态'
,
'type'
:
'ir.actions.act_window'
,
'res_model'
:
'cc.ship.package'
,
'view_mode'
:
'tree,form'
,
'domain'
:
[(
'id'
,
'in'
,
parcels
.
ids
)],
}
def
export_order_big_package_xls_action
(
self
):
error_order
=
[]
for
item
in
self
:
item
.
ship_package_ids
parcel_ids
=
item
.
big_package_ids
.
mapped
(
'ship_package_ids'
)
if
not
parcel_ids
:
error_order
.
append
(
item
.
master_business_no
)
continue
good_parcels
=
parcel_ids
.
filtered
(
lambda
x
:
x
.
item_text
)
if
len
(
good_parcels
)
==
0
:
error_order
.
append
(
item
.
master_business_no
)
if
error_order
:
raise
ValidationError
(
f
"{','.join(error_order)},没有任何商品信息可导出报关数据"
)
arr
=
[
item
.
id
for
item
in
self
]
return
{
'type'
:
'ir.actions.act_url'
,
'url'
:
'/export/flight_package/xls/
%
s/
%
s'
%
(
arr
,
self
.
select_type
),
'target'
:
'new'
,
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论