From 6d3793ee3026b1a2154042bd3501b58c530f9b8d Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Mon, 12 May 2025 15:21:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=8B=A8=E5=8D=95=E5=B0=B1=E7=BB=AA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/purchase_order.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index 5b4a6e4b..7d5d6161 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -121,21 +121,16 @@ class PurchaseOrder(models.Model): if not is_available: raise UserError('请先完成坯料入库') for production_id in productions: - work_ids = production_id.workorder_ids.filtered( - lambda wk: wk.state not in ['done', 'rework', 'cancel']) - if not work_ids: - continue - min_sequence_wk = min(work_ids, key=lambda wk: wk.sequence) - if min_sequence_wk.is_subcontract: - picking_id = production_id.picking_ids.filtered( + picking_id = production_id.picking_ids.filtered( lambda wk: wk.location_id.name == '制造前' and wk.location_dest_id.name == '外协加工区') - move_out = picking_id.move_ids - for mo in move_out: - if mo.state != 'done': - mo.write({'state': 'assigned', 'production_id': False}) - if not mo.move_line_ids: - self.env['stock.move.line'].create( - mo.get_move_line(production_id, min_sequence_wk)) + move_out = picking_id.move_ids + for mo in move_out: + if mo.state != 'done': + mo.write({'state': 'assigned', 'production_id': False}) + if not mo.move_line_ids: + self.env['stock.move.line'].create( + mo.get_move_line(production_id,False)) + # product = self.env['mrp.production'].search([('product_id', '=', product_id)], limit=1) # match = re.search(r'(S\d{5}-\d)',product.name) # pass