取消采购单时,如果该采购单关联的库存移动是由采购申请创建的,则不取消

This commit is contained in:
胡尧
2025-05-23 09:39:38 +08:00
parent 6bf666ac18
commit 1f8e118965
4 changed files with 25 additions and 0 deletions

View File

@@ -27,4 +27,14 @@ class PurchaseOrder(models.Model):
if reverse_move_ids:
reverse_move_ids.picking_id.action_cancel()
return res
def button_cancel(self):
"""
将取消的采购订单关联的库存移动撤销
"""
move_ids = self.order_line.move_dest_ids.filtered(lambda move: move.state != 'done' and not move.scrapped)
res =super(PurchaseOrder, self).button_cancel()
if move_ids.mapped('created_purchase_request_line_id'):
move_ids.write({'state': 'waiting', 'is_done': False})
return res