diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 2eab5d3fa65..64b5085cf34 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -425,4 +425,5 @@ erpnext.patches.v15_0.rename_pos_closing_entry_fields #2025-06-13 erpnext.patches.v15_0.update_pegged_currencies erpnext.patches.v15_0.set_status_cancelled_on_cancelled_pos_opening_entry_and_pos_closing_entry erpnext.patches.v15_0.set_company_on_pos_inv_merge_log -erpnext.patches.v15_0.rename_price_list_to_buying_price_list \ No newline at end of file +erpnext.patches.v15_0.rename_price_list_to_buying_price_list +erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting \ No newline at end of file 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 new file mode 100644 index 00000000000..867702ae546 --- /dev/null +++ b/erpnext/patches/v15_0/erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting.py @@ -0,0 +1,24 @@ +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()