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:
Ali 2026-01-12 18:38:19 +04:00
parent ff3924f0fd
commit 751de46b7b
1 changed files with 29 additions and 24 deletions

View File

@ -6,6 +6,7 @@ def boot_session_handler(bootinfo):
tab_hierarchy_data = {}
for doctype in all_doctypes:
try:
meta = frappe.get_meta(doctype["name"])
# Проверяем, есть ли вкладки (Tab Break) в Doctype
@ -18,7 +19,7 @@ def boot_session_handler(bootinfo):
for field in meta.fields:
if field.fieldtype == "Tab Break":
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 not in subtabs:
@ -32,6 +33,10 @@ def boot_session_handler(bootinfo):
"tabs": tabs,
"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.tab_hierarchy = tab_hierarchy_data