Skip to content

Commit

Permalink
[FIX] stock_valuation_fifo_lot
Browse files Browse the repository at this point in the history
This commit fixes the incorrect stock_valuation_layer values for deliveries when the product was received before this module was installed.
The issue occurs because the old stock_valuation_layer records do not have lot_ids values, which leads to incorrect valuation during the delivery process.
Issue link: #1350 (comment)
  • Loading branch information
AungKoKoLin1997 committed Aug 21, 2024
1 parent 0197b24 commit 71c8a67
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions stock_valuation_fifo_lot/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def _run_fifo(self, quantity, company):
candidates = self._get_fifo_candidates(company).filtered(
lambda l: move_line.lot_id in l.lot_ids
)
# Find incoming stock valuation layers that don't have lot_ids
# It may happen that the stock was received before installing this module
if not candidates:
candidates = self._get_fifo_candidates(company).filtered(
lambda l: move_line.lot_id in l.stock_move_id.lot_ids
)
for candidate in candidates:
qty_taken_on_candidate = min(
qty_to_take_on_candidates, candidate.remaining_qty
Expand Down

0 comments on commit 71c8a67

Please sign in to comment.