[FIX] purchase_mrp: Received Quantity in Purchase Order remains '0'

Steps to reproduce the bug:

- Create Product P: with BOM type - Kit and BOM components > Set - Invoicing: on delivered quantity
- Create PO with P and confirm - shipment 1 will be generated
- Cancel the PO - shipment 1 - will also get canceled
- Reset the canceled PO to quotation and confirm it - new shipment 2 will be generated
- Validate the shipment and receive product KIT

Bug:

Check PO - 'Received Qty' was not updated

Inspired from: https://github.com/odoo/odoo/commit/c2dfdc3081764a492a94024f1fb57e15636b04c9

opw:1889303

closes odoo/odoo#27622
This commit is contained in:
Goffin Simon
2018-10-10 11:34:37 +00:00
parent 26d67991c2
commit d211ea5f7c
+2 -1
View File
@@ -23,7 +23,8 @@ class PurchaseOrderLine(models.Model):
# In the case of a kit, we need to check if all components are shipped. Since the BOM might
# have changed, we don't compute the quantities but verify the move state.
if bom:
bom_delivered = all([move.state == 'done' for move in self.move_ids])
moves = self.move_ids.filtered(lambda m: m.picking_id and m.picking_id.state != 'cancel')
bom_delivered = all([move.state == 'done' for move in moves])
if bom_delivered:
return self.product_qty
else: