[FIX] purchase: cancelled procurement
If two MOs are using the same PO, when we cancel the first MO, the check availability of second MO is not working. The incoming shipment of the Purchase Order has the first MO's move_id as the destination move. When we cancel the first MO, the incoming shipment of Purchase Order still holds the first MO's move. Because of that reason, the check availability is not working for the second MO. While setting the destination move for the stock moves of the incoming shipment, it should ignore the cancelled procurements. Closes #17701 opw-748074 Courtesy of @suganthikarunanithi
This commit is contained in:
@@ -673,7 +673,7 @@ class PurchaseOrderLine(models.Model):
|
||||
}
|
||||
# Fullfill all related procurements with this po line
|
||||
diff_quantity = self.product_qty - qty
|
||||
for procurement in self.procurement_ids:
|
||||
for procurement in self.procurement_ids.filtered(lambda p: p.state != 'cancel'):
|
||||
# If the procurement has some moves already, we should deduct their quantity
|
||||
sum_existing_moves = sum(x.product_qty for x in procurement.move_ids if x.state != 'cancel')
|
||||
existing_proc_qty = procurement.product_id.uom_id._compute_quantity(sum_existing_moves, procurement.product_uom)
|
||||
|
||||
Reference in New Issue
Block a user