提交 4fd4bb31 authored 作者: 贺阳's avatar 贺阳

1、提单右上角的大包小包统计优化 不统计已取消的,对应的查看也是

2、提单关联的接口优化,大包修改
上级 3438083d
...@@ -44,7 +44,7 @@ class CcBigPackage(models.Model): ...@@ -44,7 +44,7 @@ class CcBigPackage(models.Model):
goods_qty = fields.Integer(string='Package Qty', compute='_compute_big_package_qty', store=True) goods_qty = fields.Integer(string='Package Qty', compute='_compute_big_package_qty', store=True)
# 计算包裹数量 # 计算包裹数量
@api.depends('ship_package_ids', 'goods_ids') @api.depends('ship_package_ids', 'goods_ids', 'ship_package_ids.is_cancel', 'goods_ids.is_cancel')
def _compute_big_package_qty(self): def _compute_big_package_qty(self):
for big_package in self: for big_package in self:
# 计算包裹数量,不包括取消的包裹 # 计算包裹数量,不包括取消的包裹
...@@ -67,7 +67,7 @@ class CcBigPackage(models.Model): ...@@ -67,7 +67,7 @@ class CcBigPackage(models.Model):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'cc.ship.package', 'res_model': 'cc.ship.package',
'view_mode': 'tree,form', 'view_mode': 'tree,form',
'domain': [('big_package_id', '=', self.id)], 'domain': [('big_package_id', '=', self.id), ('is_cancel', '=', False)],
} }
# 创建显示商品的action # 创建显示商品的action
...@@ -78,7 +78,7 @@ class CcBigPackage(models.Model): ...@@ -78,7 +78,7 @@ class CcBigPackage(models.Model):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'cc.package.good', 'res_model': 'cc.package.good',
'view_mode': 'tree,form', 'view_mode': 'tree,form',
'domain': [('big_package_id', '=', self.id)], 'domain': [('big_package_id', '=', self.id), ('is_cancel', '=', False)],
} }
...@@ -382,7 +382,7 @@ class CcShipPackage(models.Model): ...@@ -382,7 +382,7 @@ class CcShipPackage(models.Model):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'cc.package.good', 'res_model': 'cc.package.good',
'view_mode': 'tree,form', 'view_mode': 'tree,form',
'domain': [('bl_line_id', '=', self.id)], 'domain': [('bl_line_id', '=', self.id), ('is_cancel', '=', False)],
} }
# 翻译 # 翻译
...@@ -470,14 +470,15 @@ class CcBL(models.Model): ...@@ -470,14 +470,15 @@ class CcBL(models.Model):
('bl_no_uniq', 'unique(bl_no)', 'The Bill of Loading No. must be unique.') ('bl_no_uniq', 'unique(bl_no)', 'The Bill of Loading No. must be unique.')
] ]
@api.depends('big_package_ids', 'big_package_ids.tally_state') @api.depends('big_package_ids', 'big_package_ids.tally_state', 'big_package_ids.is_cancel')
def cal_tally_big_package_qty(self): def cal_tally_big_package_qty(self):
""" """
已理货的大包数量 已理货的大包数量
""" """
for item in self: for item in self:
item.tally_big_package_qty = len( item.tally_big_package_qty = len(
item.big_package_ids.filtered(lambda package: package.tally_state == 'checked_goods')) item.big_package_ids.filtered(
lambda package: package.tally_state == 'checked_goods' and not package.is_cancel))
# 提单号 # 提单号
bl_no = fields.Char(string='B/L No', index=True) bl_no = fields.Char(string='B/L No', index=True)
...@@ -776,13 +777,16 @@ class CcBL(models.Model): ...@@ -776,13 +777,16 @@ class CcBL(models.Model):
# } # }
# 添加计算方法,根据bl_line_ids计算bl_total_line,bl_total_qty,bl_total_amount # 添加计算方法,根据bl_line_ids计算bl_total_line,bl_total_qty,bl_total_amount
@api.depends('ship_package_ids', 'big_package_ids', 'good_ids', 'ship_package_ids.total_value') @api.depends('ship_package_ids', 'big_package_ids', 'good_ids', 'ship_package_ids.is_cancel',
'big_package_ids.is_cancel', 'good_ids.is_cancel', 'ship_package_ids.total_value')
def _compute_bl_total(self): def _compute_bl_total(self):
for bl in self: for bl in self:
bl.bl_total_amount = sum(line.total_value for line in bl.ship_package_ids) ship_package_ids = bl.ship_package_ids.filtered(lambda pack: not pack.is_cancel) # 未取消的小包
bl.bl_total_big_qty = len(bl.big_package_ids) big_package_ids = bl.big_package_ids.filtered(lambda pack: not pack.is_cancel) # 未取消的大包
bl.bl_ship_package_qty = len(bl.ship_package_ids) bl.bl_total_amount = sum(line.total_value for line in ship_package_ids)
bl.bl_total_qty = len(bl.good_ids) bl.bl_total_big_qty = len(big_package_ids)
bl.bl_ship_package_qty = len(ship_package_ids)
bl.bl_total_qty = len(bl.good_ids.filtered(lambda good: not good.is_cancel))
# 所属客户 # 所属客户
customer_id = fields.Many2one('res.partner', string='Customer') customer_id = fields.Many2one('res.partner', string='Customer')
...@@ -826,7 +830,7 @@ class CcBL(models.Model): ...@@ -826,7 +830,7 @@ class CcBL(models.Model):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'cc.big.package', 'res_model': 'cc.big.package',
'view_mode': 'tree,form', 'view_mode': 'tree,form',
'domain': [('bl_id', '=', self.id)], 'domain': [('bl_id', '=', self.id), ('is_cancel', '=', False)],
} }
def action_show_big_package_tally(self): def action_show_big_package_tally(self):
...@@ -836,7 +840,7 @@ class CcBL(models.Model): ...@@ -836,7 +840,7 @@ class CcBL(models.Model):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'cc.big.package', 'res_model': 'cc.big.package',
'view_mode': 'tree,form', 'view_mode': 'tree,form',
'domain': [('bl_id', '=', self.id), ('tally_state', '=', 'checked_goods')], 'domain': [('bl_id', '=', self.id), ('is_cancel', '=', False), ('tally_state', '=', 'checked_goods')],
} }
# 创建显示包裹的action # 创建显示包裹的action
...@@ -847,7 +851,7 @@ class CcBL(models.Model): ...@@ -847,7 +851,7 @@ class CcBL(models.Model):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'cc.ship.package', 'res_model': 'cc.ship.package',
'view_mode': 'tree,form', 'view_mode': 'tree,form',
'domain': [('bl_id', '=', self.id)], 'domain': [('bl_id', '=', self.id), ('is_cancel', '=', False)],
} }
# 创建显示商品的action # 创建显示商品的action
...@@ -858,7 +862,7 @@ class CcBL(models.Model): ...@@ -858,7 +862,7 @@ class CcBL(models.Model):
'type': 'ir.actions.act_window', 'type': 'ir.actions.act_window',
'res_model': 'cc.package.good', 'res_model': 'cc.package.good',
'view_mode': 'tree,form', 'view_mode': 'tree,form',
'domain': [('bl_id', '=', self.id)], 'domain': [('bl_id', '=', self.id), ('is_cancel', '=', False)],
} }
# 增加清关截止日期 # 增加清关截止日期
......
...@@ -118,7 +118,8 @@ class TTApi(http.Controller): ...@@ -118,7 +118,8 @@ class TTApi(http.Controller):
[('logistic_order_no', '=', logistic_order_no)]) [('logistic_order_no', '=', logistic_order_no)])
if (ship_pachage_obj and (not ship_pachage_obj.bl_id or if (ship_pachage_obj and (not ship_pachage_obj.bl_id or
ship_pachage_obj.bl_id.is_cancel)) or not ship_pachage_obj: ship_pachage_obj.bl_id.is_cancel)) or not ship_pachage_obj:
ship_package = dict(logistic_order_no=package.get('provider_order_id'), ship_package = dict(is_cancel=False, cancel_reason=False,
logistic_order_no=package.get('provider_order_id'),
tracking_no=package.get('tracking_no'), tracking_no=package.get('tracking_no'),
customer_ref=package.get('declaretion_bill_id'), customer_ref=package.get('declaretion_bill_id'),
internal_account_number="", internal_account_number="",
...@@ -281,7 +282,7 @@ class TTApi(http.Controller): ...@@ -281,7 +282,7 @@ class TTApi(http.Controller):
# 默认创建清关文件明细 # 默认创建清关文件明细
file_name_arr = ['主单', '货站提货POD', 'Manifest格式和数据(cvs/excel格式,系统目前不支持,线下提供或保留现有方式)', file_name_arr = ['主单', '货站提货POD', 'Manifest格式和数据(cvs/excel格式,系统目前不支持,线下提供或保留现有方式)',
'海关CDS申报单(import和授权方式检查拉齐等)', '尾程交接POD(待大包数量和箱号)'] '海关CDS申报单(import和授权方式检查拉齐等)', '尾程交接POD(待大包数量和箱号)']
sel.env['cc.clearance.file'].sudo().create_clearance_file_func(file_name_arr, bl.id) request.env['cc.clearance.file'].sudo().create_clearance_file_func(file_name_arr, bl.id)
else: else:
if declare_type == 'update' and bl.state == 'draft': if declare_type == 'update' and bl.state == 'draft':
bl.write(bl_vals) bl.write(bl_vals)
...@@ -290,20 +291,27 @@ class TTApi(http.Controller): ...@@ -290,20 +291,27 @@ class TTApi(http.Controller):
if big_bag_list and len(big_bag_list) > 0: if big_bag_list and len(big_bag_list) > 0:
# 删除大包数据 # 删除大包数据
for package in bl.big_package_ids: for package in bl.big_package_ids:
package.bl_id = False
package.unlink() package.unlink()
for big_bag in big_bag_list: for big_bag in big_bag_list:
big_bag_no = big_bag.get('big_bag_no') big_bag_no = big_bag.get('big_bag_no')
# 检查big_bag_no是否已经存在 # 检查big_bag_no是否已经存在
big_package = request.env['cc.big.package'].sudo().search(
[('big_package_no', '=', big_bag_no)], limit=1)
if not big_package:
big_package_vals = dict(bl_id=bl.id, big_package_vals = dict(bl_id=bl.id,
big_package_no=big_bag.get('big_bag_no'), big_package_no=big_bag.get('big_bag_no'),
next_provider_name=big_bag.get('next_provider_name')) next_provider_name=big_bag.get('next_provider_name'))
big_package = request.env['cc.big.package'].sudo().search(
[('big_package_no', '=', big_bag_no)], limit=1)
if not big_package:
big_package = request.env['cc.big.package'].sudo().create(big_package_vals) big_package = request.env['cc.big.package'].sudo().create(big_package_vals)
else:
big_package.write(big_package_vals)
# 生成cc.ship.package # 生成cc.ship.package
package_list = big_bag.get('package_list') package_list = big_bag.get('package_list') # 大包下的小包
if package_list and len(package_list) > 0: if package_list and len(package_list) > 0:
# 本身提单的小包解除关联
for ship in bl.ship_package_ids:
ship.bl_id = False
ship.big_package_id = False
package_ids = [package.get('provider_order_id') for package in package_list] package_ids = [package.get('provider_order_id') for package in package_list]
ship_packages = request.env['cc.ship.package'].sudo().search( ship_packages = request.env['cc.ship.package'].sudo().search(
[('logistic_order_no', 'in', package_ids)]) [('logistic_order_no', 'in', package_ids)])
...@@ -335,7 +343,7 @@ class TTApi(http.Controller): ...@@ -335,7 +343,7 @@ class TTApi(http.Controller):
methods=["POST", "GET"], csrf=False, cors="*") methods=["POST", "GET"], csrf=False, cors="*")
def mawb_copy_upload(self, **kw): def mawb_copy_upload(self, **kw):
# 接收提单的附件信息 # 接收提单的附件信息
_logger.info('mawb_copy_upload kw:%s' % kw) # _logger.info('mawb_copy_upload kw:%s' % kw)
res = { res = {
"code": 0, "code": 0,
"msg": "", "msg": "",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论