mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-15 15:45:01 +00:00
Merge pull request #46965 from rohitwaghchaure/fixed-reposting-error-recreate-ledgers
fix: Recreate Stock Ledgers issue
This commit is contained in:
@@ -555,7 +555,7 @@ class SellingController(StockController):
|
||||
self.doctype, self.name, d.item_code, self.return_against, item_row=d
|
||||
)
|
||||
|
||||
def update_stock_ledger(self):
|
||||
def update_stock_ledger(self, allow_negative_stock=False):
|
||||
self.update_reserved_qty()
|
||||
|
||||
sl_entries = []
|
||||
@@ -585,7 +585,7 @@ class SellingController(StockController):
|
||||
):
|
||||
sl_entries.append(self.get_sle_for_source_warehouse(d))
|
||||
|
||||
self.make_sl_entries(sl_entries)
|
||||
self.make_sl_entries(sl_entries, allow_negative_stock=allow_negative_stock)
|
||||
|
||||
def get_sle_for_source_warehouse(self, item_row):
|
||||
serial_and_batch_bundle = (
|
||||
|
||||
@@ -255,10 +255,10 @@ class RepostItemValuation(Document):
|
||||
"""Recreate Stock Ledger Entries for the transaction."""
|
||||
if self.based_on == "Transaction" and self.recreate_stock_ledgers:
|
||||
doc = frappe.get_doc(self.voucher_type, self.voucher_no)
|
||||
doc.docstatus = 2
|
||||
doc.update_stock_ledger(allow_negative_stock=True, via_landed_cost_voucher=True)
|
||||
doc.db_set("docstatus", 2)
|
||||
doc.update_stock_ledger(allow_negative_stock=True)
|
||||
|
||||
doc.docstatus = 1
|
||||
doc.db_set("docstatus", 1)
|
||||
doc.update_stock_ledger(allow_negative_stock=True)
|
||||
|
||||
|
||||
|
||||
@@ -1368,7 +1368,7 @@ class StockEntry(StockController):
|
||||
)
|
||||
)
|
||||
|
||||
def update_stock_ledger(self):
|
||||
def update_stock_ledger(self, allow_negative_stock=False):
|
||||
sl_entries = []
|
||||
finished_item_row = self.get_finished_item_row()
|
||||
|
||||
@@ -1382,7 +1382,7 @@ class StockEntry(StockController):
|
||||
if self.docstatus == 2:
|
||||
sl_entries.reverse()
|
||||
|
||||
self.make_sl_entries(sl_entries)
|
||||
self.make_sl_entries(sl_entries, allow_negative_stock=allow_negative_stock)
|
||||
|
||||
def get_finished_item_row(self):
|
||||
finished_item_row = None
|
||||
|
||||
@@ -663,7 +663,7 @@ class StockReconciliation(StockController):
|
||||
title=_("Stock Reservation"),
|
||||
)
|
||||
|
||||
def update_stock_ledger(self):
|
||||
def update_stock_ledger(self, allow_negative_stock=False):
|
||||
"""find difference between current and expected entries
|
||||
and create stock ledger entries based on the difference"""
|
||||
from erpnext.stock.stock_ledger import get_previous_sle
|
||||
@@ -719,7 +719,11 @@ class StockReconciliation(StockController):
|
||||
sl_entries.append(self.get_sle_for_items(row))
|
||||
|
||||
if sl_entries:
|
||||
allow_negative_stock = cint(frappe.db.get_single_value("Stock Settings", "allow_negative_stock"))
|
||||
if not allow_negative_stock:
|
||||
allow_negative_stock = cint(
|
||||
frappe.db.get_single_value("Stock Settings", "allow_negative_stock")
|
||||
)
|
||||
|
||||
self.make_sl_entries(sl_entries, allow_negative_stock=allow_negative_stock)
|
||||
|
||||
def make_adjustment_entry(self, row, sl_entries):
|
||||
|
||||
Reference in New Issue
Block a user