mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-08 15:42:52 +00:00
Merge pull request #48940 from mihir-kandoi/fix-missing-account-gl-entry-subcontracting
fix: failing subcontracting patch
This commit is contained in:
@@ -427,7 +427,7 @@ erpnext.patches.v15_0.set_status_cancelled_on_cancelled_pos_opening_entry_and_po
|
|||||||
erpnext.patches.v15_0.set_company_on_pos_inv_merge_log
|
erpnext.patches.v15_0.set_company_on_pos_inv_merge_log
|
||||||
erpnext.patches.v15_0.update_payment_ledger_entries_against_advance_doctypes
|
erpnext.patches.v15_0.update_payment_ledger_entries_against_advance_doctypes
|
||||||
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 #2025-07-31
|
erpnext.patches.v15_0.repost_gl_entries_with_no_account_subcontracting #2025-08-04
|
||||||
erpnext.patches.v15_0.patch_missing_buying_price_list_in_material_request
|
erpnext.patches.v15_0.patch_missing_buying_price_list_in_material_request
|
||||||
erpnext.patches.v15_0.remove_sales_partner_from_consolidated_sales_invoice
|
erpnext.patches.v15_0.remove_sales_partner_from_consolidated_sales_invoice
|
||||||
erpnext.patches.v15_0.add_company_payment_gateway_account
|
erpnext.patches.v15_0.add_company_payment_gateway_account
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ import frappe
|
|||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
docs = frappe.get_all(
|
def cancel_incorrect_gl_entries(gl_entries):
|
||||||
"GL Entry",
|
table = frappe.qb.DocType("GL Entry")
|
||||||
filters={"voucher_type": "Subcontracting Receipt", "account": ["is", "not set"], "is_cancelled": 0},
|
frappe.qb.update(table).set(table.is_cancelled, 1).where(table.name.isin(gl_entries)).run()
|
||||||
pluck="voucher_no",
|
|
||||||
)
|
def recreate_gl_entries(voucher_nos):
|
||||||
for doc in docs:
|
for doc in voucher_nos:
|
||||||
doc = frappe.get_doc("Subcontracting Receipt", doc)
|
doc = frappe.get_doc("Subcontracting Receipt", doc)
|
||||||
for item in doc.supplied_items:
|
for item in doc.supplied_items:
|
||||||
account, cost_center = frappe.db.get_values(
|
account, cost_center = frappe.db.get_values(
|
||||||
@@ -19,7 +19,14 @@ def execute():
|
|||||||
if not item.cost_center:
|
if not item.cost_center:
|
||||||
item.db_set("cost_center", 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()
|
doc.make_gl_entries()
|
||||||
|
|
||||||
|
docs = frappe.get_all(
|
||||||
|
"GL Entry",
|
||||||
|
fields=["name", "voucher_no"],
|
||||||
|
filters={"voucher_type": "Subcontracting Receipt", "account": ["is", "not set"], "is_cancelled": 0},
|
||||||
|
)
|
||||||
|
|
||||||
|
if docs:
|
||||||
|
cancel_incorrect_gl_entries([d.name for d in docs])
|
||||||
|
recreate_gl_entries([d.voucher_no for d in docs])
|
||||||
|
|||||||
Reference in New Issue
Block a user