From 513daa7c2b5daf3f3049c57ccdd5039a63ac7d13 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 26 Feb 2025 17:39:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E5=8D=95=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 | 59 +++++++++++++------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/sf_manufacturing/wizard/sale_order_cancel.py b/sf_manufacturing/wizard/sale_order_cancel.py index b9e879d8..11cf0922 100644 --- a/sf_manufacturing/wizard/sale_order_cancel.py +++ b/sf_manufacturing/wizard/sale_order_cancel.py @@ -382,27 +382,46 @@ class SFSaleOrderCancelLine(models.TransientModel): # 检查组件的制造单 component_mos = self.env['mrp.production'].search([ - ('origin', '=', mo.name), - ('product_id', '=', move.product_id.id) - ]) + ('origin', '=', mo.name)]) h = 0 - for comp_mo in component_mos: - h += 1 - vals = { - 'wizard_id': wizard_id, - 'sequence': sequence, - 'category': '制造', - 'doc_name': '组件制造单', - 'operation_type': '', - 'doc_number': comp_mo.name, - 'line_number': h, - '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 '' - } - lines.append(self.create(vals)) - sequence += 1 + if component_mos: + for comp_mo in component_mos: + h += 1 + vals = { + 'wizard_id': wizard_id, + 'sequence': sequence, + 'category': '制造', + 'doc_name': '组件制造单', + 'operation_type': '', + 'doc_number': comp_mo.name, + 'line_number': h, + '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 '' + } + lines.append(self.create(vals)) + sequence += 1 + + for pinking_id in comp_mo.picking_ids: + y = 0 + for move in pinking_id.move_ids: + y += 1 + vals = { + 'wizard_id': wizard_id, + 'sequence': sequence, + 'category': '子制造调拨', + 'doc_name': '库存移动', + 'doc_number': f'{comp_mo.name}-{pinking_id.name}', + 'line_number': y, + 'operation_type': pinking_id.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(pinking_id.state, pinking_id.state), + 'cancel_reason': '已有异动' if pinking_id.state not in ['cancel', 'waiting'] else '' + } + lines.append(self.create(vals)) + # 检查制造订单的质检单 quality_checks = self.env['quality.check'].search([