diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 9fea3cb1b16..2a811ec10a5 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -426,5 +426,6 @@ 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.repost_gl_entries_with_no_account_subcontracting erpnext.patches.v15_0.patch_missing_buying_price_list_in_material_request erpnext.patches.v15_0.remove_sales_partner_from_consolidated_sales_invoice 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..b2208667ea6 --- /dev/null +++ b/erpnext/patches/v15_0/repost_gl_entries_with_no_account_subcontracting.py @@ -0,0 +1,25 @@ +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) + + doc.docstatus = 2 + doc.make_gl_entries_on_cancel() + doc.docstatus = 1 + doc.make_gl_entries()