From d608b78f8cf5a942d53fe9a7208d622d21d1e2a6 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Thu, 27 Feb 2025 09:04:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9D=AF=E6=96=99=E5=A4=96=E5=8D=8F=E5=8D=95?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/wizard/sale_order_cancel.py | 51 +++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/sf_manufacturing/wizard/sale_order_cancel.py b/sf_manufacturing/wizard/sale_order_cancel.py index 11cf0922..c726d5d6 100644 --- a/sf_manufacturing/wizard/sale_order_cancel.py +++ b/sf_manufacturing/wizard/sale_order_cancel.py @@ -285,6 +285,53 @@ class SFSaleOrderCancelLine(models.TransientModel): lines.append(self.create(vals)) sequence += 1 + # 制造询价单的入库单 + for pod in purchase_orders: + pkds = self.env['stock.picking'].search([ + ('origin', '=', pod.name) + ]) + if pkds: + for pkd in pkds: + x1 = 0 + for move in pkd.move_ids: + x1 += 1 + vals = { + 'wizard_id': wizard_id, + 'sequence': sequence, + 'category': '坯料收货', + 'doc_name': '库存移动', + 'doc_number': pkd.name, + 'line_number': x1, + 'operation_type': pkd.picking_type_id.name, + '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 '' + } + lines.append(self.create(vals)) + + # + for child_pkd in self.env['stock.picking'].search([ + ('origin', '=', pkd.name) + ]): + x2 = 0 + for child_move in child_pkd.move_ids: + x2 += 1 + vals = { + 'wizard_id': wizard_id, + 'sequence': sequence, + 'category': '坯料外协', + 'doc_name': '库存移动', + 'doc_number': child_pkd.name, + 'line_number': x1, + 'operation_type': child_pkd.picking_type_id.name, + '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 '' + } + lines.append(self.create(vals)) + # 检查制造订单的领料单 if mo.picking_ids and flag: @@ -398,7 +445,8 @@ class SFSaleOrderCancelLine(models.TransientModel): 'product_name': move.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', 'cancel'] else '' + 'cancel_reason': '已有异动' if comp_mo.state not in ['technology_to_confirmed', + 'cancel'] else '' } lines.append(self.create(vals)) sequence += 1 @@ -422,7 +470,6 @@ class SFSaleOrderCancelLine(models.TransientModel): } lines.append(self.create(vals)) - # 检查制造订单的质检单 quality_checks = self.env['quality.check'].search([ ('production_id', '=', mo.id)