提交 5f1eb134 authored 作者: 贺阳's avatar 贺阳

优化

上级 36f77fb6
......@@ -23,12 +23,13 @@ class ExportBlAndPackageXlsx(http.Controller):
font_style = xlwt.easyxf('font: height 220,name 宋体,bold on; align: wrap on, vert centre, horiz center;')
num = 1
sheet1 = self.get_package_title(worksheet, font_style, num)
ship_package_obj = big_bag_obj.mapped('ship_package_ids') # 小包
ship_package_obj = big_bag_obj.mapped('ship_package_ids').filtered(lambda pack: not pack.is_cancel) # 小包
good_index = 0
parcel_export_num = request.env["ir.config_parameter"].sudo().get_param('parcel_export_num') or 50000
for parcel_idx, package_item in enumerate(ship_package_obj):
if package_item.good_ids:
for good_item in package_item.good_ids:
good_ids = package_item.good_ids.filtered(lambda good: not good.is_cancel)
if good_ids:
for good_item in good_ids:
good_index += 1
sheet1.write(good_index, 0, package_item.logistic_order_no or '') # 物流订单号 TRACKING NO.
sheet1.write(good_index, 1, package_item.customer_ref or '') # CUSTOMER REF
......@@ -124,13 +125,14 @@ class ExportBlAndPackageXlsx(http.Controller):
是否分大包,如果不分,就是提单一个文件,命名 提单号;如果分,一个提单一个大包一个文件,命名 提单号➕大包号
"""
arr = json.loads(arr)
bl_obj = http.request.env['cc.bl'].sudo().search([('id', 'in', arr)], order='id')
bl_obj = http.request.env['cc.bl'].sudo().search([('id', 'in', arr), ('is_cancel', '=', False)], order='id')
zip_buffer = io.BytesIO()
with zipfile.ZipFile(zip_buffer, 'w', zipfile.ZIP_DEFLATED) as zip_file:
if select_type == 'yes':
for bl_item in bl_obj:
for bag_item in bl_item.big_package_ids:
if len(bag_item.mapped('ship_package_ids').mapped('good_ids')) > 0:
for bag_item in bl_item.big_package_ids.filtered(lambda pack: not pack.is_cancel):
if len(bag_item.mapped('ship_package_ids').mapped('good_ids').filtered(
lambda good: not good.is_cancel)) > 0:
worksheet = self.common_package_data(bag_item)
# 将Excel保存到内存中的文件对象
excel_file = io.BytesIO()
......@@ -139,8 +141,9 @@ class ExportBlAndPackageXlsx(http.Controller):
zip_file.writestr(f"{bl_item.bl_no}-{bag_item.big_package_no}.xls", excel_file.read()) # 压缩
else:
for bl_item in bl_obj:
big_bag_obj = bl_item.big_package_ids
if len(big_bag_obj.mapped('ship_package_ids').mapped('good_ids')) > 0:
big_bag_obj = bl_item.big_package_ids.filtered(lambda pack: not pack.is_cancel)
if len(big_bag_obj.mapped('ship_package_ids').mapped('good_ids').filtered(
lambda good: not good.is_cancel)) > 0:
worksheet = self.common_package_data(big_bag_obj)
# 将Excel保存到内存中的文件对象
excel_file = io.BytesIO()
......@@ -154,18 +157,3 @@ class ExportBlAndPackageXlsx(http.Controller):
]
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_obj = http.request.env['ao.big.package'].sudo().search([('id', 'in', arr)], order='order_id')
else:
big_bag_obj = http.request.env['ao.big.package'].sudo().search([('order_id', 'in', arr)], order='order_id')
worksheet = self.common_package_data(big_bag_obj)
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
......@@ -1572,7 +1572,7 @@ msgstr "提单总大包数"
#: model_terms:ir.ui.view,arch_db:ccs_base.form_cc_bl_view
#: model_terms:ir.ui.view,arch_db:ccs_base.tree_cc_bl_view
msgid "Receive Goods Qty"
msgstr "提单总大包数"
msgstr "提单总商品数"
#. module: ccs_base
#: model_terms:ir.ui.view,arch_db:ccs_base.tree_cc_bl_view
......
......@@ -109,7 +109,7 @@
<group>
<field name="billing_weight" string="Billing Weight"/>
<field name="actual_weight" string="Actual Weight"/>
<field name="big_package_qty" string="Big Package Qty"/>
<field name="big_package_qty" string="Big Package Qty" invisible="1"/>
<field name="bl_total_big_qty" string="Receive Big Package Qty"/>
<field name="bl_ship_package_qty" string="Receive Ship Package Qty"/>
<field name="bl_total_qty" string="Receive Goods Qty"/>
......
......@@ -90,7 +90,7 @@
</h1>
<group>
<field name="customer_id" string="From Customer"/>
<field name="big_package_no" string="Big Package No"/>
<field name="big_package_no" string="Big Package No" invisible="1"/>
<field name="big_package_id" string="Big Package"/>
<field name="bl_id" string="Bill of Loading"/>
<field name="next_provider_name" string="Next Provider Name"/>
......
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, api, fields
from odoo import models, api, fields, _
from odoo.exceptions import Warning, ValidationError
PUSH_TYPE = [
......@@ -21,7 +21,7 @@ PUSH_TYPE = [
# 包括以下字段,提单, 当前节点, 更新节点, 排除面单号, 排除状态
class BatchInputShipPackageStatusWizard(models.TransientModel):
_name = 'batch.input.ship.package.status.wizard'
_description = 'Batch Update the status of the small package'#批量更新小包状态向导
_description = 'Batch Update the status of the small package' # 批量更新小包状态向导
@api.onchange('select_type', 'current_status')
def onchange_select_type(self):
......
......@@ -163,11 +163,13 @@ class CcShipPackage(models.Model):
}
]
}
logging.info('小包轨迹 push_data:%s' % push_data)
return push_data
def callback_track(self):
if not self.is_sync and self.state and self.state.tk_code:
data = self.get_callback_track_data()
logging.info('小包轨迹 data:%s' % data)
tt_api_obj = self.env["ao.tt.api"].sudo()
response = tt_api_obj.callback_track(data)
response_data = response.json()
......
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, api, fields
from odoo import models, api, fields, _
from odoo.exceptions import Warning, ValidationError
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论