mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 18:04:46 +00:00
Merge pull request #48136 from aerele/enable_dim_submit
fix(accounts):enable allow_on_submit for accounting dimensions in repost settings allowed doctypes
This commit is contained in:
@@ -111,17 +111,15 @@ class AccountingDimension(Document):
|
|||||||
def make_dimension_in_accounting_doctypes(doc, doclist=None):
|
def make_dimension_in_accounting_doctypes(doc, doclist=None):
|
||||||
if not doclist:
|
if not doclist:
|
||||||
doclist = get_doctypes_with_dimensions()
|
doclist = get_doctypes_with_dimensions()
|
||||||
|
|
||||||
doc_count = len(get_accounting_dimensions())
|
doc_count = len(get_accounting_dimensions())
|
||||||
count = 0
|
count = 0
|
||||||
repostable_doctypes = get_allowed_types_from_settings()
|
repostable_doctypes = get_allowed_types_from_settings(child_doc=True)
|
||||||
|
|
||||||
for doctype in doclist:
|
for doctype in doclist:
|
||||||
if (doc_count + 1) % 2 == 0:
|
if (doc_count + 1) % 2 == 0:
|
||||||
insert_after_field = "dimension_col_break"
|
insert_after_field = "dimension_col_break"
|
||||||
else:
|
else:
|
||||||
insert_after_field = "accounting_dimensions_section"
|
insert_after_field = "accounting_dimensions_section"
|
||||||
|
|
||||||
df = {
|
df = {
|
||||||
"fieldname": doc.fieldname,
|
"fieldname": doc.fieldname,
|
||||||
"label": doc.label,
|
"label": doc.label,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import inspect
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, qb
|
from frappe import _, qb
|
||||||
|
from frappe.desk.form.linked_with import get_child_tables_of_doctypes
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils.data import comma_and
|
from frappe.utils.data import comma_and
|
||||||
|
|
||||||
@@ -208,13 +209,29 @@ def start_repost(account_repost_doc=str) -> None:
|
|||||||
doc.make_gl_entries()
|
doc.make_gl_entries()
|
||||||
|
|
||||||
|
|
||||||
def get_allowed_types_from_settings():
|
def get_allowed_types_from_settings(child_doc: bool = False):
|
||||||
return [
|
repost_docs = [
|
||||||
x.document_type
|
x.document_type
|
||||||
for x in frappe.db.get_all(
|
for x in frappe.db.get_all(
|
||||||
"Repost Allowed Types", filters={"allowed": True}, fields=["distinct(document_type)"]
|
"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):
|
def validate_docs_for_deferred_accounting(sales_docs, purchase_docs):
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
|
# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
|
||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
# import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
||||||
|
get_accounting_dimensions,
|
||||||
|
)
|
||||||
|
from erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger import get_child_docs
|
||||||
|
|
||||||
|
|
||||||
class RepostAccountingLedgerSettings(Document):
|
class RepostAccountingLedgerSettings(Document):
|
||||||
# begin: auto-generated types
|
# begin: auto-generated types
|
||||||
@@ -17,6 +22,24 @@ class RepostAccountingLedgerSettings(Document):
|
|||||||
from erpnext.accounts.doctype.repost_allowed_types.repost_allowed_types import RepostAllowedTypes
|
from erpnext.accounts.doctype.repost_allowed_types.repost_allowed_types import RepostAllowedTypes
|
||||||
|
|
||||||
allowed_types: DF.Table[RepostAllowedTypes]
|
allowed_types: DF.Table[RepostAllowedTypes]
|
||||||
# end: auto-generated types
|
|
||||||
|
|
||||||
pass
|
# end: auto-generated types
|
||||||
|
def validate(self):
|
||||||
|
self.update_property_for_accounting_dimension()
|
||||||
|
|
||||||
|
def update_property_for_accounting_dimension(self):
|
||||||
|
doctypes = [entry.document_type for entry in self.allowed_types if entry.allowed]
|
||||||
|
if not doctypes:
|
||||||
|
return
|
||||||
|
doctypes += get_child_docs(doctypes)
|
||||||
|
|
||||||
|
set_allow_on_submit_for_dimension_fields(doctypes)
|
||||||
|
|
||||||
|
|
||||||
|
def set_allow_on_submit_for_dimension_fields(doctypes):
|
||||||
|
for dt in doctypes:
|
||||||
|
meta = frappe.get_meta(dt)
|
||||||
|
for dimension in get_accounting_dimensions():
|
||||||
|
df = meta.get_field(dimension)
|
||||||
|
if df and not df.allow_on_submit:
|
||||||
|
frappe.db.set_value("Custom Field", dt + "-" + dimension, "allow_on_submit", 1)
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ execute:frappe.db.set_single_value("Buying Settings", "project_update_frequency"
|
|||||||
execute:frappe.db.set_default("date_format", frappe.db.get_single_value("System Settings", "date_format"))
|
execute:frappe.db.set_default("date_format", frappe.db.get_single_value("System Settings", "date_format"))
|
||||||
erpnext.patches.v14_0.update_total_asset_cost_field
|
erpnext.patches.v14_0.update_total_asset_cost_field
|
||||||
erpnext.patches.v15_0.create_advance_payment_status
|
erpnext.patches.v15_0.create_advance_payment_status
|
||||||
erpnext.patches.v15_0.allow_on_submit_dimensions_for_repostable_doctypes
|
erpnext.patches.v15_0.allow_on_submit_dimensions_for_repostable_doctypes #2025-06-19
|
||||||
erpnext.patches.v14_0.create_accounting_dimensions_in_reconciliation_tool
|
erpnext.patches.v14_0.create_accounting_dimensions_in_reconciliation_tool
|
||||||
erpnext.patches.v14_0.update_flag_for_return_invoices #2024-03-22
|
erpnext.patches.v14_0.update_flag_for_return_invoices #2024-03-22
|
||||||
erpnext.patches.v15_0.create_accounting_dimensions_in_payment_request
|
erpnext.patches.v15_0.create_accounting_dimensions_in_payment_request
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ from erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger
|
|||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
for dt in get_allowed_types_from_settings():
|
for dt in get_allowed_types_from_settings(child_doc=True):
|
||||||
for dimension in get_accounting_dimensions():
|
for dimension in get_accounting_dimensions():
|
||||||
frappe.db.set_value("Custom Field", dt + "-" + dimension, "allow_on_submit", 1)
|
frappe.db.set_value("Custom Field", dt + "-" + dimension, "allow_on_submit", 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user