fix: add error handling and safe attribute access in boot_session_handler
Problem: - boot_session_handler was failing silently for some DocTypes - Direct access to field.js_parent_subtab caused AttributeError - DocTypes with errors prevented entire hierarchy from being built Solution: - Added try-except around DocType processing loop - Changed field.js_parent_subtab to getattr(field, 'js_parent_subtab', None) - Errors are logged but don't break the entire boot process Result: - All DocTypes with subtabs now properly included in tab_hierarchy - "Declaration of value added tax" and similar DocTypes now work correctly Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
ff3924f0fd
commit
751de46b7b
|
|
@ -6,6 +6,7 @@ def boot_session_handler(bootinfo):
|
||||||
tab_hierarchy_data = {}
|
tab_hierarchy_data = {}
|
||||||
|
|
||||||
for doctype in all_doctypes:
|
for doctype in all_doctypes:
|
||||||
|
try:
|
||||||
meta = frappe.get_meta(doctype["name"])
|
meta = frappe.get_meta(doctype["name"])
|
||||||
|
|
||||||
# Проверяем, есть ли вкладки (Tab Break) в Doctype
|
# Проверяем, есть ли вкладки (Tab Break) в Doctype
|
||||||
|
|
@ -18,7 +19,7 @@ def boot_session_handler(bootinfo):
|
||||||
for field in meta.fields:
|
for field in meta.fields:
|
||||||
if field.fieldtype == "Tab Break":
|
if field.fieldtype == "Tab Break":
|
||||||
tab_name = field.label
|
tab_name = field.label
|
||||||
js_parent = field.js_parent_subtab or None
|
js_parent = getattr(field, 'js_parent_subtab', None) or None
|
||||||
|
|
||||||
if js_parent:
|
if js_parent:
|
||||||
if js_parent not in subtabs:
|
if js_parent not in subtabs:
|
||||||
|
|
@ -32,6 +33,10 @@ def boot_session_handler(bootinfo):
|
||||||
"tabs": tabs,
|
"tabs": tabs,
|
||||||
"subtabs": subtabs
|
"subtabs": subtabs
|
||||||
}
|
}
|
||||||
|
except Exception as e:
|
||||||
|
# Пропускаем DocTypes с ошибками, но не ломаем весь boot
|
||||||
|
frappe.log_error(f"Error processing subtabs for {doctype['name']}: {str(e)}", "Custom Subtabs Boot Error")
|
||||||
|
continue
|
||||||
|
|
||||||
# Передаём данные на клиентскую сторону через bootinfo
|
# Передаём данные на клиентскую сторону через bootinfo
|
||||||
bootinfo.tab_hierarchy = tab_hierarchy_data
|
bootinfo.tab_hierarchy = tab_hierarchy_data
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue