diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py index 81937469f21..cdaaa6dd069 100644 --- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py +++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py @@ -111,17 +111,15 @@ class AccountingDimension(Document): def make_dimension_in_accounting_doctypes(doc, doclist=None): if not doclist: doclist = get_doctypes_with_dimensions() - doc_count = len(get_accounting_dimensions()) count = 0 - repostable_doctypes = get_allowed_types_from_settings() + repostable_doctypes = get_allowed_types_from_settings(child_doc=True) for doctype in doclist: if (doc_count + 1) % 2 == 0: insert_after_field = "dimension_col_break" else: insert_after_field = "accounting_dimensions_section" - df = { "fieldname": doc.fieldname, "label": doc.label, diff --git a/erpnext/accounts/doctype/repost_accounting_ledger/repost_accounting_ledger.py b/erpnext/accounts/doctype/repost_accounting_ledger/repost_accounting_ledger.py index aec26b280c4..37863036492 100644 --- a/erpnext/accounts/doctype/repost_accounting_ledger/repost_accounting_ledger.py +++ b/erpnext/accounts/doctype/repost_accounting_ledger/repost_accounting_ledger.py @@ -5,6 +5,7 @@ import inspect import frappe from frappe import _, qb +from frappe.desk.form.linked_with import get_child_tables_of_doctypes from frappe.model.document import Document from frappe.utils.data import comma_and @@ -208,13 +209,29 @@ def start_repost(account_repost_doc=str) -> None: doc.make_gl_entries() -def get_allowed_types_from_settings(): - return [ +def get_allowed_types_from_settings(child_doc: bool = False): + repost_docs = [ x.document_type for x in frappe.db.get_all( "Repost Allowed Types", filters={"allowed": True}, fields=["distinct(document_type)"] ) ] + result = repost_docs + + if repost_docs and child_doc: + result.extend(get_child_docs(repost_docs)) + + return result + + +def get_child_docs(doc: list) -> list: + child_doc = [] + doc = get_child_tables_of_doctypes(doc) + for child_list in doc.values(): + for child in child_list: + if child.get("child_table"): + child_doc.append(child["child_table"]) + return child_doc def validate_docs_for_deferred_accounting(sales_docs, purchase_docs):