提交 78d8fad3 authored 作者: 贺阳's avatar 贺阳

删除打包和货物 改为sql删除

上级 7c1ad553
......@@ -110,7 +110,6 @@ class TTApi(http.Controller):
packages = json.loads(param_json)
# 根据 packages内容生成申报信息,包括ship package和package good
for package in packages:
try:
# 根据物流订单号判断是否已存在,已存在的话就更新
logistic_order_no = package.get('provider_order_id')
......@@ -168,7 +167,6 @@ class TTApi(http.Controller):
total_value=package.get('value').get('goods_value'),
customer_id=request.env["ir.config_parameter"].sudo().get_param(
'tt_customer_id') or False) # 增加客户信息
# 生成package good
if package.get('items') and len(package.get('items')) > 0:
package_vals = []
......@@ -208,8 +206,20 @@ class TTApi(http.Controller):
# 用ship_package生成cc.ship.package
request.env['cc.ship.package'].sudo().create(ship_package)
else:
for good in ship_pachage_obj.good_ids:
good.unlink()
good_ids = ship_pachage_obj.good_ids
where_sql = "" if len(good_ids) <= 0 else (
"where id=%s" % good_ids[0].id if len(
good_ids) == 1 else "where id in {0}".format(tuple(
good_ids.ids)))
if where_sql and len(good_ids) > 0:
good_del_sql = "delete from cc_package_good {0}".format(where_sql)
request._cr.execute(good_del_sql)
request._cr.commit()
# for good in ship_pachage_obj.good_ids:
# good.bl_line_id = False
# good.big_package_id = False
# good.bl_id = False
# good.unlink()
ship_pachage_obj.write(ship_package)
request._cr.commit()
except Exception as e_package:
......@@ -290,10 +300,19 @@ class TTApi(http.Controller):
# 生成cc.big.package
big_bag_list = kws.get('big_bag_list')
if big_bag_list and len(big_bag_list) > 0:
# 删除大包数据
for package in bl.big_package_ids:
package.bl_id = False
package.unlink()
# 删除大包数据 改为sql
big_package_ids = bl.big_package_ids
where_sql = "" if len(big_package_ids) <= 0 else (
"where id=%s" % big_package_ids[0].id if len(
big_package_ids) == 1 else "where id in {0}".format(tuple(
big_package_ids.ids)))
if where_sql and len(big_package_ids) > 0:
del_sql = "delete from cc_big_package {0}".format(where_sql)
request._cr.execute(del_sql)
request._cr.commit()
# for package in bl.big_package_ids:
# package.bl_id = False
# package.unlink()
# 本身提单的小包解除关联
for ship in bl.ship_package_ids:
ship.bl_id = False
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论