Unomptimized code with universal fields, with bugs
This commit is contained in:
parent
a8250e53e7
commit
2f077b7752
|
|
@ -1,24 +1,46 @@
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_doctype_fields(doctype):
|
def get_doctype_fields(doctype):
|
||||||
meta = frappe.get_meta(doctype)
|
meta = frappe.get_meta(doctype)
|
||||||
fields = []
|
fields = []
|
||||||
|
|
||||||
# Получаем все int-поля
|
# Получаем все int-поля
|
||||||
for field in meta.fields:
|
for field in meta.fields:
|
||||||
if field.fieldtype in ["Int", "Float", "Currency"]:
|
if field.fieldtype in ["Int", "Float", "Currency"]:
|
||||||
fields.append({"fieldname": field.fieldname, "label": field.label})
|
fields.append({"fieldname": field.fieldname, "label": field.label})
|
||||||
|
# Проверяем таблицы внутри DocType (например, items в Sales Invoice)
|
||||||
# Проверяем таблицы внутри DocType (например, `items` в `Sales Invoice`)
|
|
||||||
for child in meta.fields:
|
for child in meta.fields:
|
||||||
if child.fieldtype == "Table":
|
if child.fieldtype == "Table":
|
||||||
child_meta = frappe.get_meta(child.options)
|
child_meta = frappe.get_meta(child.options)
|
||||||
for sub_field in child_meta.fields:
|
for sub_field in child_meta.fields:
|
||||||
if sub_field.fieldtype in ["Int", "Float", "Currency"]:
|
if sub_field.fieldtype in ["Int", "Float", "Currency"]:
|
||||||
fields.append({
|
fields.append({
|
||||||
"fieldname": f"{child.fieldname}_{sub_field.fieldname}",
|
"fieldname": f"{child.fieldname}{sub_field.fieldname}",
|
||||||
"label": f"{child.label} → {sub_field.label}"
|
"label": f"{child.label} → {sub_field.label}"
|
||||||
})
|
})
|
||||||
|
return fields
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_all_doctype_fields(doctype):
|
||||||
|
"""Получение отфильтрованных полей DocType без служебных полей"""
|
||||||
|
meta = frappe.get_meta(doctype)
|
||||||
|
fields = []
|
||||||
|
|
||||||
|
# Типы полей, которые нужно исключить
|
||||||
|
excluded_types = [
|
||||||
|
"Tab Break", "Column Break", "Button", "Section Break", "Column Break",
|
||||||
|
"HTML", "Table", "Attach", "Attach Image", "Code", "Text Editor", "Image",
|
||||||
|
"Read Only", "Heading", "Fold", "Table MultiSelect"
|
||||||
|
]
|
||||||
|
|
||||||
|
# Получаем все поля, которые не входят в исключенные типы
|
||||||
|
for field in meta.fields:
|
||||||
|
if field.fieldname and field.fieldtype not in excluded_types:
|
||||||
|
fields.append({
|
||||||
|
"fieldname": field.fieldname,
|
||||||
|
"label": field.label or field.fieldname,
|
||||||
|
"fieldtype": field.fieldtype
|
||||||
|
})
|
||||||
|
|
||||||
|
# Мы не добавляем поля из таблиц, так как они были исключены из списка
|
||||||
|
|
||||||
return fields
|
return fields
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -7,6 +7,7 @@
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"target_doctype",
|
"target_doctype",
|
||||||
"formula_storage",
|
"formula_storage",
|
||||||
|
"universal_fields_storage",
|
||||||
"formula_fields",
|
"formula_fields",
|
||||||
"test"
|
"test"
|
||||||
],
|
],
|
||||||
|
|
@ -30,11 +31,16 @@
|
||||||
{
|
{
|
||||||
"fieldname": "test",
|
"fieldname": "test",
|
||||||
"fieldtype": "HTML"
|
"fieldtype": "HTML"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "universal_fields_storage",
|
||||||
|
"fieldtype": "Text",
|
||||||
|
"label": "universal_fields_storage"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2025-02-27 19:12:22.113845",
|
"modified": "2025-03-06 13:11:19.311286",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Formula Editor",
|
"module": "Formula Editor",
|
||||||
"name": "Formula Editor",
|
"name": "Formula Editor",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue