From b53723acad0f2c24ba272023849194194661f775 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Fri, 18 Jul 2025 15:33:31 +0530 Subject: [PATCH] fix: include cost center in patch --- ..._entries_with_no_account_subcontracting.py | 24 ----------------- ..._entries_with_no_account_subcontracting.py | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+), 24 deletions(-) delete mode 100644 erpnext/patches/v15_0/erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting.py create mode 100644 erpnext/patches/v15_0/repost_gl_entries_with_no_account_subcontracting.py diff --git a/erpnext/patches/v15_0/erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting.py b/erpnext/patches/v15_0/erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting.py deleted file mode 100644 index 867702ae546..00000000000 --- a/erpnext/patches/v15_0/erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting.py +++ /dev/null @@ -1,24 +0,0 @@ -import frappe - - -def execute(): - docs = frappe.get_all( - "GL Entry", - filters={"voucher_type": "Subcontracting Receipt", "account": ["is", "not set"], "is_cancelled": 0}, - pluck="voucher_no", - ) - for doc in docs: - doc = frappe.get_doc("Subcontracting Receipt", doc) - for item in doc.supplied_items: - if not item.expense_account: - account = frappe.get_value( - "Subcontracting Receipt Item", item.reference_name, "expense_account" - ) - item.db_set("expense_account", account) - repost_doc = frappe.new_doc("Repost Item Valuation") - repost_doc.voucher_type = "Subcontracting Receipt" - repost_doc.voucher_no = doc.name - repost_doc.based_on = "Transaction" - repost_doc.company = doc.company - repost_doc.save() - repost_doc.submit() diff --git a/erpnext/patches/v15_0/repost_gl_entries_with_no_account_subcontracting.py b/erpnext/patches/v15_0/repost_gl_entries_with_no_account_subcontracting.py new file mode 100644 index 00000000000..7e06a4050d5 --- /dev/null +++ b/erpnext/patches/v15_0/repost_gl_entries_with_no_account_subcontracting.py @@ -0,0 +1,26 @@ +import frappe + + +def execute(): + docs = frappe.get_all( + "GL Entry", + filters={"voucher_type": "Subcontracting Receipt", "account": ["is", "not set"], "is_cancelled": 0}, + pluck="voucher_no", + ) + for doc in docs: + doc = frappe.get_doc("Subcontracting Receipt", doc) + for item in doc.supplied_items: + account, cost_center = frappe.db.get_values( + "Subcontracting Receipt Item", item.reference_name, ["expense_account", "cost_center"] + )[0] + if not item.expense_account: + item.db_set("expense_account", account) + if not item.cost_center: + item.db_set("cost_center", cost_center) + repost_doc = frappe.new_doc("Repost Item Valuation") + repost_doc.voucher_type = "Subcontracting Receipt" + repost_doc.voucher_no = doc.name + repost_doc.based_on = "Transaction" + repost_doc.company = doc.company + repost_doc.save() + repost_doc.submit()