diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index fcdff21591..3f25e0222f 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -204,10 +204,10 @@ class StockController(AccountsController): from erpnext.stock.stock_ledger import make_sl_entries make_sl_entries(sl_entries, is_amended, allow_negative_stock, via_landed_cost_voucher) - def make_gl_entries_on_cancel(self): + def make_gl_entries_on_cancel(self, repost_future_gle=True): if frappe.db.sql("""select name from `tabGL Entry` where voucher_type=%s and voucher_no=%s""", (self.doctype, self.name)): - self.make_gl_entries() + self.make_gl_entries(repost_future_gle) def get_serialized_items(self): serialized_items = [] @@ -261,7 +261,7 @@ def update_gl_entries_after(posting_date, posting_time, for_warehouses=None, for future_stock_vouchers = get_future_stock_vouchers(posting_date, posting_time, for_warehouses, for_items) gle = get_voucherwise_gl_entries(future_stock_vouchers, posting_date) - + for voucher_type, voucher_no in future_stock_vouchers: existing_gle = gle.get((voucher_type, voucher_no), []) voucher_obj = frappe.get_doc(voucher_type, voucher_no) diff --git a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py index ac59e06ca8..cdf7263126 100644 --- a/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py +++ b/erpnext/stock/doctype/landed_cost_voucher/landed_cost_voucher.py @@ -84,7 +84,7 @@ class LandedCostVoucher(Document): self.update_landed_cost() def update_landed_cost(self): - for d in self.get("items"): + for d in self.get("purchase_receipts"): doc = frappe.get_doc(d.receipt_document_type, d.receipt_document) # set landed cost voucher amount in pr item @@ -103,7 +103,7 @@ class LandedCostVoucher(Document): # update stock & gl entries for cancelled state of PR doc.docstatus = 2 doc.update_stock_ledger(allow_negative_stock=True, via_landed_cost_voucher=True) - doc.make_gl_entries_on_cancel() + doc.make_gl_entries_on_cancel(repost_future_gle=False) # update stock & gl entries for submit state of PR