fix: stock adjustment entry to make stock balance zero (backport #48245) (#48247)

fix: stock adjustment entry to make stock balance zero (#48245)

(cherry picked from commit 66eeda6410)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
mergify[bot]
2025-06-24 22:16:24 +05:30
committed by GitHub
parent a913cfea7e
commit 41d22d0255
2 changed files with 13 additions and 0 deletions

View File

@@ -175,6 +175,9 @@ class StockLedgerEntry(Document):
if frappe.flags.in_test and frappe.flags.ignore_serial_batch_bundle_validation:
return
if self.is_adjustment_entry:
return
if not self.get("via_landed_cost_voucher"):
SerialBatchBundle(
sle=self,

View File

@@ -478,6 +478,8 @@ class StockReconciliation(StockController):
frappe.db.set_value("Serial and Batch Entry", batch.name, update_values)
def remove_items_with_no_change(self):
from erpnext.stock.stock_ledger import get_stock_value_difference
"""Remove items if qty or rate is not changed"""
self.difference_amount = 0.0
@@ -513,6 +515,14 @@ class StockReconciliation(StockController):
company=self.company,
)
if not item_dict.get("qty") and not item.qty and not item.valuation_rate and not item.current_qty:
difference_amount = get_stock_value_difference(
item.item_code, item.warehouse, self.posting_date, self.posting_time, self.name
)
if abs(difference_amount) > 0:
return True
if (
(item.qty is None or item.qty == item_dict.get("qty"))
and (item.valuation_rate is None or item.valuation_rate == item_dict.get("rate"))