mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[IMP] write method replaced for backported implementation
This commit is contained in:
@@ -104,3 +104,34 @@ class StockMove(models.Model):
|
|||||||
def _prepare_merge_moves_distinct_fields(self):
|
def _prepare_merge_moves_distinct_fields(self):
|
||||||
res = super()._prepare_merge_moves_distinct_fields()
|
res = super()._prepare_merge_moves_distinct_fields()
|
||||||
return res + ["rma_line_id"]
|
return res + ["rma_line_id"]
|
||||||
|
|
||||||
|
def _set_lot_ids(self, lot_ids):
|
||||||
|
lots = self.env["stock.move"].browse(lot_ids)
|
||||||
|
self.ensure_one()
|
||||||
|
for move in self:
|
||||||
|
if move.product_id.tracking != "serial":
|
||||||
|
continue
|
||||||
|
move_lines_commands = []
|
||||||
|
if move.picking_type_id.show_reserved is False:
|
||||||
|
mls = move.move_line_nosuggest_ids
|
||||||
|
else:
|
||||||
|
mls = move.move_line_ids
|
||||||
|
mls = mls.filtered(lambda ml: ml.lot_id)
|
||||||
|
for ml in mls:
|
||||||
|
if ml.qty_done and ml.lot_id not in lots:
|
||||||
|
move_lines_commands.append((2, ml.id))
|
||||||
|
ls = move.move_line_ids.lot_id
|
||||||
|
for lot in lots:
|
||||||
|
if lot not in ls:
|
||||||
|
move_line_vals = self._prepare_move_line_vals(quantity=0)
|
||||||
|
move_line_vals["lot_id"] = lot.id
|
||||||
|
move_line_vals["lot_name"] = lot.name
|
||||||
|
move_line_vals["product_uom_id"] = move.product_id.uom_id.id
|
||||||
|
move_line_vals["qty_done"] = 1
|
||||||
|
move_lines_commands.append((0, 0, move_line_vals))
|
||||||
|
else:
|
||||||
|
move_line = move.move_line_ids.filtered(
|
||||||
|
lambda line: line.lot_id.id == lot.id
|
||||||
|
)
|
||||||
|
move_line.qty_done = 1
|
||||||
|
move.write({"move_line_ids": move_lines_commands})
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
# Force the reservation of the RMA specific lot for incoming shipments.
|
# Force the reservation of the RMA specific lot for incoming shipments.
|
||||||
move.move_line_ids.unlink()
|
move.move_line_ids.unlink()
|
||||||
if move.product_id.tracking == "serial":
|
if move.product_id.tracking == "serial":
|
||||||
move.write({"lot_ids": [(6, 0, move.rma_line_id.lot_id.ids)]})
|
move._set_lot_ids(move.rma_line_id.lot_id.ids)
|
||||||
move.move_line_ids.write({"product_uom_qty": 1, "qty_done": 0})
|
move.move_line_ids.write({"product_uom_qty": 1, "qty_done": 0})
|
||||||
elif move.product_id.tracking == "lot":
|
elif move.product_id.tracking == "lot":
|
||||||
if picking_type == "incoming":
|
if picking_type == "incoming":
|
||||||
|
|||||||
Reference in New Issue
Block a user