From 36c08d08357d0384a1238ac37f7a9bf1585fc554 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Thu, 23 Feb 2023 16:46:37 +0530 Subject: [PATCH] fix: Add patches to create accounting dimension in Closing Balance --- ...counting_dimensions_for_closing_balance.py | 31 +++++++++++++++++++ .../patches/v14_0/update_closing_balances.py | 9 ++++++ 2 files changed, 40 insertions(+) create mode 100644 erpnext/patches/v14_0/create_accounting_dimensions_for_closing_balance.py create mode 100644 erpnext/patches/v14_0/update_closing_balances.py diff --git a/erpnext/patches/v14_0/create_accounting_dimensions_for_closing_balance.py b/erpnext/patches/v14_0/create_accounting_dimensions_for_closing_balance.py new file mode 100644 index 0000000000..375782171c --- /dev/null +++ b/erpnext/patches/v14_0/create_accounting_dimensions_for_closing_balance.py @@ -0,0 +1,31 @@ +import frappe +from frappe.custom.doctype.custom_field.custom_field import create_custom_field + + +def execute(): + accounting_dimensions = frappe.db.get_all( + "Accounting Dimension", fields=["fieldname", "label", "document_type", "disabled"] + ) + + if not accounting_dimensions: + return + + doctype = "Closing Balance" + + for d in accounting_dimensions: + field = frappe.db.get_value("Custom Field", {"dt": doctype, "fieldname": d.fieldname}) + + if field: + continue + + df = { + "fieldname": d.fieldname, + "label": d.label, + "fieldtype": "Link", + "options": d.document_type, + "insert_after": "accounting_dimensions_section", + } + + create_custom_field(doctype, df, ignore_validate=True) + + frappe.clear_cache(doctype=doctype) diff --git a/erpnext/patches/v14_0/update_closing_balances.py b/erpnext/patches/v14_0/update_closing_balances.py new file mode 100644 index 0000000000..cd120b553c --- /dev/null +++ b/erpnext/patches/v14_0/update_closing_balances.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors +# License: MIT. See LICENSE + + +# import frappe + + +def execute(): + pass