From 4b7308fdcd9aa079fcf1dfa5978924100a5711fd Mon Sep 17 00:00:00 2001 From: liaodanlong Date: Tue, 31 Dec 2024 12:54:16 +0800 Subject: [PATCH] =?UTF-8?q?sf-=E5=88=B6=E9=80=A0-=E5=A4=96=E5=8D=8F?= =?UTF-8?q?=E5=B7=A5=E5=8D=95-=E8=B0=83=E6=8B=A8=E5=8D=95=E5=B7=B2?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/stock.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 1d880d66..1d1cd991 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -685,7 +685,11 @@ class StockPicking(models.Model): 'sf_manufacturing.outcontract_picking_in').id, outcontract_picking_type_out = self.env.ref( 'sf_manufacturing.outcontract_picking_out').id, - moves_in = self.env['stock.move'].sudo().create( + context = dict(self.env.context) + context.update({ + 'default_production_id': item.id, # 添加额外信息到 context 中 + }) + moves_in = self.env['stock.move'].sudo().with_context(context).create( self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_in, procurement_group_id.id, move_dest_id)) picking_in = self.create( @@ -694,7 +698,8 @@ class StockPicking(models.Model): moves_in.write( {'picking_id': picking_in.id, 'state': 'waiting'}) moves_in._assign_picking_post_process(new=new_picking) - moves_out = self.env['stock.move'].sudo().create( + # self.env.context.get('default_production_id') + moves_out = self.env['stock.move'].sudo().with_context(context).create( self.env['stock.move']._get_stock_move_values_Res(item, outcontract_picking_type_out, procurement_group_id.id, moves_in.id)) workorder.write({'move_subcontract_workorder_ids': [(6, 0, [moves_in.id, moves_out.id])]}) @@ -774,6 +779,7 @@ class ReStockMove(models.Model): 'origin': item.name, 'group_id': group_id, 'move_dest_ids': [(6, 0, [move_dest_ids])] if move_dest_ids else False, + # 'production_id': item.id, # 'route_ids': False if not route else [(4, route.id)], 'date_deadline': datetime.now(), 'picking_type_id': picking_type_id,