diff --git a/sf_manufacturing/wizard/sale_order_cancel.py b/sf_manufacturing/wizard/sale_order_cancel.py index 98347a2e..519519cd 100644 --- a/sf_manufacturing/wizard/sale_order_cancel.py +++ b/sf_manufacturing/wizard/sale_order_cancel.py @@ -232,11 +232,9 @@ class SFSaleOrderCancelLine(models.TransientModel): } lines.append(self.create(vals)) - - # 检查销售订单直接关联的采购单 purchase_orders = self.env['purchase.order'].search([ - ('origin', '=', order.name) + ('origin', 'like', f'%{order.name}%') ]) if purchase_orders: c = 0 @@ -280,7 +278,7 @@ class SFSaleOrderCancelLine(models.TransientModel): 'product_name': move.product_id.name if move.product_id else '', 'quantity': move.product_uom_qty, 'doc_state': map_dict.get(pkd.state, pkd.state), - 'cancel_reason': '已有异动' if pkd.state not in ['draft', 'cancel'] else '' + 'cancel_reason': '已有异动' if pkd.state not in ['waiting', 'cancel', 'confirmed'] else '' } lines.append(self.create(vals)) @@ -302,8 +300,8 @@ class SFSaleOrderCancelLine(models.TransientModel): 'product_name': child_move.product_id.name if child_move.product_id else '', 'quantity': child_move.product_uom_qty, 'doc_state': map_dict.get(child_pkd.state, child_pkd.state), - 'cancel_reason': '已有异动' if child_pkd.state not in ['draft', - 'cancel'] else '' + 'cancel_reason': '已有异动' if child_pkd.state not in ['waiting', + 'cancel', 'confirmed'] else '' } lines.append(self.create(vals)) @@ -336,7 +334,7 @@ class SFSaleOrderCancelLine(models.TransientModel): # 检查制造订单关联的采购单 purchase_orders = self.env['purchase.order'].search([ - ('origin', '=', mo.name) + ('origin', 'like', f'%{mo.name}%') ]) if purchase_orders: e = 0 @@ -516,7 +514,7 @@ class SFSaleOrderCancelLine(models.TransientModel): 'operation_type': '', 'doc_number': comp_mo.name, 'line_number': h, - 'product_name': move.product_id.name, + 'product_name': f'[{comp_mo.product_id.default_code}] {comp_mo.product_id.name}', 'quantity': comp_mo.product_qty, 'doc_state': map_dict.get(comp_mo.state, comp_mo.state), 'cancel_reason': '已有异动' if comp_mo.state not in ['technology_to_confirmed', @@ -540,7 +538,7 @@ class SFSaleOrderCancelLine(models.TransientModel): 'product_name': move.product_id.name if move.product_id else '', 'quantity': move.product_uom_qty, 'doc_state': map_dict.get(pinking_id.state, pinking_id.state), - 'cancel_reason': '已有异动' if pinking_id.state not in ['cancel', 'waiting'] else '' + 'cancel_reason': '已有异动' if pinking_id.state not in ['cancel', 'waiting', 'assigned'] else '' } lines.append(self.create(vals))