mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_quant_manual_assign: add prepare lines method
This commit is contained in:
committed by
Alexis de Lattre
parent
ae5744c083
commit
f564392ddb
@@ -82,30 +82,35 @@ class AssignManualQuants(models.TransientModel):
|
||||
)
|
||||
q_lines = []
|
||||
for quant in available_quants:
|
||||
line = {
|
||||
"quant_id": quant.id,
|
||||
"on_hand": quant.quantity,
|
||||
"location_id": quant.location_id.id,
|
||||
"lot_id": quant.lot_id.id,
|
||||
"package_id": quant.package_id.id,
|
||||
"owner_id": quant.owner_id.id,
|
||||
"selected": False,
|
||||
}
|
||||
move_lines = move.move_line_ids.filtered(
|
||||
lambda ml: (
|
||||
ml.location_id == quant.location_id
|
||||
and ml.lot_id == quant.lot_id
|
||||
and ml.owner_id == quant.owner_id
|
||||
and ml.package_id == quant.package_id
|
||||
)
|
||||
)
|
||||
line["qty"] = sum(move_lines.mapped("product_uom_qty"))
|
||||
line["selected"] = bool(line["qty"])
|
||||
line["reserved"] = quant.reserved_quantity - line["qty"]
|
||||
line = self._prepare_wizard_line(move, quant)
|
||||
q_lines.append(line)
|
||||
res.update({"quants_lines": [(0, 0, x) for x in q_lines], "move_id": move.id})
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _prepare_wizard_line(self, move, quant):
|
||||
line = {
|
||||
"quant_id": quant.id,
|
||||
"on_hand": quant.quantity,
|
||||
"location_id": quant.location_id.id,
|
||||
"lot_id": quant.lot_id.id,
|
||||
"package_id": quant.package_id.id,
|
||||
"owner_id": quant.owner_id.id,
|
||||
"selected": False,
|
||||
}
|
||||
move_lines = move.move_line_ids.filtered(
|
||||
lambda ml: (
|
||||
ml.location_id == quant.location_id
|
||||
and ml.lot_id == quant.lot_id
|
||||
and ml.owner_id == quant.owner_id
|
||||
and ml.package_id == quant.package_id
|
||||
)
|
||||
)
|
||||
line["qty"] = sum(move_lines.mapped("product_uom_qty"))
|
||||
line["selected"] = bool(line["qty"])
|
||||
line["reserved"] = quant.reserved_quantity - line["qty"]
|
||||
return line
|
||||
|
||||
|
||||
class AssignManualQuantsLines(models.TransientModel):
|
||||
_name = "assign.manual.quants.lines"
|
||||
|
||||
Reference in New Issue
Block a user