mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-25 06:02:09 +01:00
fix: incorrect available quantity in BIN
(cherry picked from commit 9e5e2de5d5)
This commit is contained in:
committed by
Mergify
parent
e251180c1a
commit
5a9452f4a3
@@ -443,12 +443,11 @@ class update_entries_after(object):
|
|||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
self.process_sle(sle)
|
self.process_sle(sle)
|
||||||
|
self.update_bin_data(sle)
|
||||||
|
|
||||||
if sle.dependant_sle_voucher_detail_no:
|
if sle.dependant_sle_voucher_detail_no:
|
||||||
entries_to_fix = self.get_dependent_entries_to_fix(entries_to_fix, sle)
|
entries_to_fix = self.get_dependent_entries_to_fix(entries_to_fix, sle)
|
||||||
|
|
||||||
self.update_bin()
|
|
||||||
|
|
||||||
if self.exceptions:
|
if self.exceptions:
|
||||||
self.raise_exceptions()
|
self.raise_exceptions()
|
||||||
|
|
||||||
@@ -1065,6 +1064,18 @@ class update_entries_after(object):
|
|||||||
else:
|
else:
|
||||||
raise NegativeStockError(message)
|
raise NegativeStockError(message)
|
||||||
|
|
||||||
|
def update_bin_data(self, sle):
|
||||||
|
bin_name = get_or_make_bin(sle.item_code, sle.warehouse)
|
||||||
|
frappe.db.set_value(
|
||||||
|
"Bin",
|
||||||
|
bin_name,
|
||||||
|
{
|
||||||
|
"actual_qty": sle.qty_after_transaction,
|
||||||
|
"valuation_rate": sle.valuation_rate,
|
||||||
|
"stock_value": sle.stock_value,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
def update_bin(self):
|
def update_bin(self):
|
||||||
# update bin for each warehouse
|
# update bin for each warehouse
|
||||||
for warehouse, data in self.data.items():
|
for warehouse, data in self.data.items():
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ def get_bin(item_code, warehouse):
|
|||||||
|
|
||||||
|
|
||||||
def get_or_make_bin(item_code: str, warehouse: str) -> str:
|
def get_or_make_bin(item_code: str, warehouse: str) -> str:
|
||||||
bin_record = frappe.db.get_value("Bin", {"item_code": item_code, "warehouse": warehouse})
|
bin_record = frappe.get_cached_value("Bin", {"item_code": item_code, "warehouse": warehouse})
|
||||||
|
|
||||||
if not bin_record:
|
if not bin_record:
|
||||||
bin_obj = _create_bin(item_code, warehouse)
|
bin_obj = _create_bin(item_code, warehouse)
|
||||||
|
|||||||
Reference in New Issue
Block a user