From b582e9c42c30765f83821726976ce18120534167 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Tue, 6 Feb 2024 19:13:48 +0530 Subject: [PATCH] fix: remove file from the disk after the completion of reposting (cherry picked from commit fb330d1b5a8b2620d23c5a899c26ea240966b20c) --- .../repost_item_valuation/repost_item_valuation.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py index 79b8ee30cf..4cb2fdcd4d 100644 --- a/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py +++ b/erpnext/stock/doctype/repost_item_valuation/repost_item_valuation.py @@ -286,6 +286,7 @@ def repost(doc): repost_gl_entries(doc) doc.set_status("Completed") + remove_attached_file(doc.name) except Exception as e: if frappe.flags.in_test: @@ -314,6 +315,13 @@ def repost(doc): frappe.db.commit() +def remove_attached_file(docname): + if file_name := frappe.db.get_value( + "File", {"attached_to_name": docname, "attached_to_doctype": "Repost Item Valuation"}, "name" + ): + frappe.delete_doc("File", file_name) + + def repost_sl_entries(doc): if doc.based_on == "Transaction": repost_future_sle(