mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 04:59:18 +00:00
refactor: move allowed doctypes to accounts settings
- dropped 'allowed' field
(cherry picked from commit d5c58277cb)
This commit is contained in:
@@ -10,6 +10,9 @@ from frappe.custom.doctype.property_setter.property_setter import make_property_
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from frappe.utils import cint
|
from frappe.utils import cint
|
||||||
|
|
||||||
|
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
|
||||||
|
get_accounting_dimensions,
|
||||||
|
)
|
||||||
from erpnext.accounts.utils import sync_auto_reconcile_config
|
from erpnext.accounts.utils import sync_auto_reconcile_config
|
||||||
|
|
||||||
SELLING_DOCTYPES = [
|
SELLING_DOCTYPES = [
|
||||||
@@ -143,6 +146,7 @@ class AccountsSettings(Document):
|
|||||||
frappe.clear_cache()
|
frappe.clear_cache()
|
||||||
|
|
||||||
self.validate_and_sync_auto_reconcile_config()
|
self.validate_and_sync_auto_reconcile_config()
|
||||||
|
self.update_property_for_accounting_dimension()
|
||||||
|
|
||||||
def validate_stale_days(self):
|
def validate_stale_days(self):
|
||||||
if not self.allow_stale and cint(self.stale_days) <= 0:
|
if not self.allow_stale and cint(self.stale_days) <= 0:
|
||||||
@@ -189,6 +193,17 @@ class AccountsSettings(Document):
|
|||||||
title=_("Auto Tax Settings Error"),
|
title=_("Auto Tax Settings Error"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def update_property_for_accounting_dimension(self):
|
||||||
|
doctypes = [entry.document_type for entry in self.repost_allowed_types]
|
||||||
|
if not doctypes:
|
||||||
|
return
|
||||||
|
|
||||||
|
from erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger import get_child_docs
|
||||||
|
|
||||||
|
doctypes += get_child_docs(doctypes)
|
||||||
|
|
||||||
|
set_allow_on_submit_for_dimension_fields(doctypes)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def drop_ar_sql_procedures(self):
|
def drop_ar_sql_procedures(self):
|
||||||
from erpnext.accounts.report.accounts_receivable.accounts_receivable import InitSQLProceduresForAR
|
from erpnext.accounts.report.accounts_receivable.accounts_receivable import InitSQLProceduresForAR
|
||||||
@@ -228,3 +243,12 @@ def create_property_setter_for_hiding_field(doctype, field_name, hide):
|
|||||||
"Check",
|
"Check",
|
||||||
validate_fields_for_doctype=False,
|
validate_fields_for_doctype=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
|||||||
@@ -6,9 +6,7 @@
|
|||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"document_type",
|
"document_type"
|
||||||
"column_break_sfzb",
|
|
||||||
"allowed"
|
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -17,28 +15,19 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Doctype",
|
"label": "Doctype",
|
||||||
"options": "DocType"
|
"options": "DocType"
|
||||||
},
|
|
||||||
{
|
|
||||||
"default": "0",
|
|
||||||
"fieldname": "allowed",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Allowed"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"fieldname": "column_break_sfzb",
|
|
||||||
"fieldtype": "Column Break"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"grid_page_length": 50,
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2024-03-27 13:10:32.415806",
|
"modified": "2026-04-14 16:53:16.806714",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Repost Allowed Types",
|
"name": "Repost Allowed Types",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [],
|
"permissions": [],
|
||||||
|
"row_format": "Dynamic",
|
||||||
"sort_field": "creation",
|
"sort_field": "creation",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": []
|
"states": []
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class RepostAllowedTypes(Document):
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from frappe.types import DF
|
from frappe.types import DF
|
||||||
|
|
||||||
allowed: DF.Check
|
|
||||||
document_type: DF.Link | None
|
document_type: DF.Link | None
|
||||||
parent: DF.Data
|
parent: DF.Data
|
||||||
parentfield: DF.Data
|
parentfield: DF.Data
|
||||||
|
|||||||
@@ -475,3 +475,4 @@ erpnext.patches.v16_0.remove_payables_receivables_workspace
|
|||||||
erpnext.patches.v16_0.co_by_product_patch
|
erpnext.patches.v16_0.co_by_product_patch
|
||||||
erpnext.patches.v16_0.depends_on_inv_dimensions
|
erpnext.patches.v16_0.depends_on_inv_dimensions
|
||||||
erpnext.patches.v16_0.uom_category
|
erpnext.patches.v16_0.uom_category
|
||||||
|
erpnext.patches.v16_0.merge_repost_settings_to_accounts_settings
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import frappe
|
||||||
|
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
if allowed := frappe.get_hooks("repost_allowed_doctypes"):
|
||||||
|
accounts_settings = frappe.get_doc("Accounts Settings")
|
||||||
|
for x in allowed:
|
||||||
|
if x not in [t.document_type for t in accounts_settings.repost_allowed_types]:
|
||||||
|
accounts_settings.append("repost_allowed_types", {"document_type": x})
|
||||||
|
accounts_settings.save()
|
||||||
Reference in New Issue
Block a user