成品入库单已经完成-工单还有【回退】按钮-还能回退成功 问题处理

This commit is contained in:
liaodanlong
2025-02-25 16:29:58 +08:00
parent 78b58d4fb8
commit 2e648dea4e

View File

@@ -645,6 +645,16 @@ class StockPicking(models.Model):
stock_picking = stock_picking_list.filtered(lambda p: p.state not in ("done", "cancel"))
if sale_id and not stock_picking:
sale_id.write({'state': 'delivered'})
if self.location_dest_id.name == '成品存货区' and self.state == 'done':
for move in self.move_ids:
for production in self.sale_order_id.mrp_production_ids:
moves = self.env['stock.move'].search([
('name', '=', production.name),
('state', '!=', 'cancel')
])
finish_move = next((move for move in moves if move.location_dest_id.name == '制造后'), None)
if finish_move.id in move.move_orig_ids.ids and finish_move.state == 'done':
production.workorder_ids.write({'back_button_display': False})
return res
# 创建 外协出库入单