fix: allow editable accounting dimensions for repostable doctypes
diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
index 295cd98..5258214 100644
--- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
+++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
@@ -11,6 +11,10 @@
from frappe.model.document import Document
from frappe.utils import cstr
+from erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger import (
+ get_allowed_types_from_settings,
+)
+
class AccountingDimension(Document):
# begin: auto-generated types
@@ -106,6 +110,7 @@
doc_count = len(get_accounting_dimensions())
count = 0
+ repostable_doctypes = get_allowed_types_from_settings()
for doctype in doclist:
@@ -121,6 +126,7 @@
"options": doc.document_type,
"insert_after": insert_after_field,
"owner": "Administrator",
+ "allow_on_submit": 1 if doctype in repostable_doctypes else 0,
}
meta = frappe.get_meta(doctype, cached=False)
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 647ab38..2a02cd7 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -13,6 +13,10 @@
from erpnext.accounts.doctype.invoice_discounting.invoice_discounting import (
get_party_account_based_on_invoice_discounting,
)
+from erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger import (
+ validate_docs_for_deferred_accounting,
+ validate_docs_for_voucher_types,
+)
from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import (
get_party_tax_withholding_details,
)
@@ -149,6 +153,10 @@
if not self.title:
self.title = self.get_title()
+ def validate_for_repost(self):
+ validate_docs_for_voucher_types(["Journal Entry"])
+ validate_docs_for_deferred_accounting([self.name], [])
+
def submit(self):
if len(self.accounts) > 100:
msgprint(_("The task has been enqueued as a background job."), alert=True)
@@ -177,7 +185,9 @@
self.needs_repost = self.check_if_fields_updated(
fields_to_check=[], child_tables={"accounts": []}
)
- self.db_set("repost_required", self.needs_repost)
+ if self.needs_repost:
+ self.validate_for_repost()
+ self.db_set("repost_required", self.needs_repost)
def on_cancel(self):
# References for this Journal are removed on the `on_cancel` event in accounts_controller