fix: missing account in GL entries (subcontracting)

This commit is contained in:
Mihir Kandoi
2025-07-18 15:13:59 +05:30
parent cc2ca58721
commit c022b80e05
2 changed files with 26 additions and 1 deletions

View File

@@ -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
erpnext.patches.v15_0.rename_price_list_to_buying_price_list
erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting

View File

@@ -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()