mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[FIX] mrp_production_serial_matrix: use qty reserved for selected MO.
User should be able to use the matrix when the MO is reserved and select the lots that are available plus the ones reserved specifically for the MO.
This commit is contained in:
@@ -71,11 +71,8 @@ class MrpProductionSerialMatrix(models.TransientModel):
|
||||
if not ll.component_lot_id:
|
||||
continue
|
||||
lot_consumption.setdefault(ll.component_lot_id, 0)
|
||||
available_quantity = self.env["stock.quant"]._get_available_quantity(
|
||||
ll.component_id,
|
||||
ll.production_id.location_src_id,
|
||||
lot_id=ll.component_lot_id,
|
||||
)
|
||||
free_qty, reserved_qty = ll._get_available_and_reserved_quantities()
|
||||
available_quantity = free_qty + reserved_qty
|
||||
if (
|
||||
available_quantity - lot_consumption[ll.component_lot_id]
|
||||
< ll.lot_qty
|
||||
|
||||
@@ -36,3 +36,18 @@ class MrpProductionSerialMatrix(models.TransientModel):
|
||||
]
|
||||
)
|
||||
rec.allowed_component_lot_ids = available_quants.mapped("lot_id")
|
||||
|
||||
def _get_available_and_reserved_quantities(self):
|
||||
self.ensure_one()
|
||||
available_quantity = self.env["stock.quant"]._get_available_quantity(
|
||||
self.component_id,
|
||||
self.production_id.location_src_id,
|
||||
lot_id=self.component_lot_id,
|
||||
)
|
||||
move_lines = self.production_id.move_raw_ids.mapped("move_line_ids").filtered(
|
||||
lambda l: l.product_id == self.component_id
|
||||
and l.lot_id == self.component_lot_id
|
||||
and l.state not in ["done", "cancel"]
|
||||
)
|
||||
specifically_reserved_quantity = sum(move_lines.mapped("product_uom_qty"))
|
||||
return available_quantity, specifically_reserved_quantity
|
||||
|
||||
Reference in New Issue
Block a user