mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[FIX] rma: add lot to pickings created from wizard on RMA lines
This commit is contained in:
committed by
Lois Rilo
parent
844db3b93c
commit
13e3a4bf77
@@ -60,3 +60,9 @@ class StockMove(models.Model):
|
||||
return self.move_dest_ids[0]._get_last_usage()
|
||||
else:
|
||||
return self.location_dest_id.usage
|
||||
|
||||
def _should_bypass_reservation(self):
|
||||
res = super(StockMove, self)._should_bypass_reservation()
|
||||
if self.env.context.get("force_no_bypass_reservation"):
|
||||
return False
|
||||
return res
|
||||
|
||||
@@ -189,11 +189,55 @@ class RmaMakePicking(models.TransientModel):
|
||||
|
||||
def action_create_picking(self):
|
||||
self._create_picking()
|
||||
move_line_model = self.env["stock.move.line"]
|
||||
picking_type = self.env.context.get("picking_type")
|
||||
pickings = self.env["stock.picking"].browse()
|
||||
if picking_type == "outgoing":
|
||||
pickings = self.mapped("item_ids.line_id")._get_out_pickings()
|
||||
action = self.item_ids.line_id.action_view_out_shipments()
|
||||
else:
|
||||
pickings = self.mapped("item_ids.line_id")._get_in_pickings()
|
||||
action = self.item_ids.line_id.action_view_in_shipments()
|
||||
for move in pickings.move_lines.filtered(
|
||||
lambda x: x.state not in ("draft", "cancel", "done")
|
||||
and x.rma_line_id
|
||||
and x.product_id.tracking in ("lot", "serial")
|
||||
and x.rma_line_id.lot_id
|
||||
):
|
||||
move.move_line_ids.unlink()
|
||||
if move.product_id.tracking == "serial":
|
||||
move.write(
|
||||
{
|
||||
"lot_ids": [(6, 0, move.rma_line_id.lot_id.ids)],
|
||||
}
|
||||
)
|
||||
move.move_line_ids.write(
|
||||
{
|
||||
"product_uom_qty": 1,
|
||||
"qty_done": 0,
|
||||
}
|
||||
)
|
||||
elif move.product_id.tracking == "lot":
|
||||
if picking_type == "incoming":
|
||||
qty = self.item_ids.filtered(
|
||||
lambda x: x.line_id.id == move.rma_line_id.id
|
||||
).qty_to_receive
|
||||
else:
|
||||
qty = self.item_ids.filtered(
|
||||
lambda x: x.line_id.id == move.rma_line_id.id
|
||||
).qty_to_deliver
|
||||
move_line_data = move._prepare_move_line_vals()
|
||||
move_line_data.update(
|
||||
{
|
||||
"lot_id": move.rma_line_id.lot_id.id,
|
||||
"product_uom_id": move.product_id.uom_id.id,
|
||||
"qty_done": 0,
|
||||
"product_uom_qty": qty,
|
||||
}
|
||||
)
|
||||
move_line_model.create(move_line_data)
|
||||
if picking_type == "incoming":
|
||||
pickings.with_context(force_no_bypass_reservation=True).action_assign()
|
||||
return action
|
||||
|
||||
def action_cancel(self):
|
||||
|
||||
Reference in New Issue
Block a user