diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 78e4ec0c..1cdbb7af 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -862,10 +862,9 @@ class ResMrpWorkOrder(models.Model): ('location_dest_id', '=', self.env['stock.location'].search( [('barcode', 'ilike', 'VL-SPOC')]).id), ('origin', '=', self.production_id.name)]) - purchase = self.env['purchase.order'].search([('origin', 'ilike', self.production_id.name)]) - if purchase and move_out: + if move_out: move_out.write({'state': 'assigned'}) - self.env['stock.move.line'].create(move_out.get_move_line(purchase, self)) + self.env['stock.move.line'].create(move_out.get_move_line(self.production_id, self)) # move_out._action_assign() if self.state == 'waiting' or self.state == 'ready' or self.state == 'progress': diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py index 9e826fb5..9234060f 100644 --- a/sf_manufacturing/models/stock.py +++ b/sf_manufacturing/models/stock.py @@ -487,10 +487,10 @@ class StockPicking(models.Model): ('location_dest_id', '=', self.env['stock.location'].search( [('barcode', 'ilike', 'VL-SPOC')]).id), ('origin', '=', self.origin)]) - if self.id == move_out.picking_id.id: - if move_out.move_line_ids.workorder_id.state not in ['progress']: - raise UserError( - _('该出库单里源单据内的单号为%s的工单还未开始,不能进行验证操作!' % move_out.move_line_ids.workorder_id.name)) + # if self.id == move_out.picking_id.id: + # if move_out.move_line_ids.workorder_id.state not in ['progress']: + # raise UserError( + # _('该出库单里源单据内的单号为%s的工单还未开始,不能进行验证操作!' % move_out.move_line_ids.workorder_id.name)) # 入库单验证 move_in = self.env['stock.move'].search( [('location_dest_id', '=', self.env['stock.location'].search( @@ -506,18 +506,17 @@ class StockPicking(models.Model): res = super().button_validate() if res is True: if self.id == move_out.picking_id.id: - if move_out.move_line_ids.workorder_id.state == 'progress': - move_in = self.env['stock.move'].search( - [('location_dest_id', '=', self.env['stock.location'].search( - [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id), - ('location_id', '=', self.env['stock.location'].search( - [('barcode', 'ilike', 'VL-SPOC')]).id), - ('origin', '=', self.origin)]) - # purchase = self.env['purchase.order'].search([('origin', '=', self.origin)]) - if move_in: - move_in.write({'state': 'assigned'}) - purchase = self.env['purchase.order'].search([('origin', '=', self.origin)]) - self.env['stock.move.line'].create(move_in.get_move_line(purchase, None)) + # if move_out.move_line_ids.workorder_id.state == 'progress': + move_in = self.env['stock.move'].search( + [('location_dest_id', '=', self.env['stock.location'].search( + [('barcode', 'ilike', 'WH-PREPRODUCTION')]).id), + ('location_id', '=', self.env['stock.location'].search( + [('barcode', 'ilike', 'VL-SPOC')]).id), + ('origin', '=', self.origin)]) + production = self.env['mrp.production'].search([('name', '=', self.origin)]) + if move_in: + move_in.write({'state': 'assigned'}) + self.env['stock.move.line'].create(move_in.get_move_line(production, None)) return res @@ -599,7 +598,7 @@ class ReStockMove(models.Model): 'state': 'confirmed', } - def get_move_line(self, purchase, sorted_workorders): + def get_move_line(self, production_id, sorted_workorders): return { 'move_id': self.id, 'product_id': self.product_id.id, @@ -608,7 +607,7 @@ class ReStockMove(models.Model): 'location_dest_id': self.picking_id.location_dest_id.id, 'picking_id': self.picking_id.id, 'reserved_uom_qty': 1.0, - 'lot_id': purchase.picking_ids.move_line_ids.lot_id.id, + 'lot_id': production_id.move_line_raw_ids.lot_id.id, 'company_id': self.company_id.id, # 'workorder_id': '' if not sorted_workorders else sorted_workorders.id, # 'production_id': '' if not sorted_workorders else sorted_workorders.production_id.id,