Fixed all known bugs, and added formulas for table rows.

This commit is contained in:
Ali 2025-04-04 16:36:59 +04:00
parent 36e1402a77
commit 1d7a662901
3 changed files with 2758 additions and 594 deletions

View File

@ -7,17 +7,29 @@ def get_doctype_fields(doctype):
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, "fieldtype": field.fieldtype}) fields.append({"fieldname": field.fieldname, "label": field.label, "fieldtype": field.fieldtype})
# Проверяем таблицы внутри DocType (например, items в Sales Invoice)
# Проверяем таблицы внутри DocType
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}",
"fieldtype": sub_field.fieldtype "fieldtype": sub_field.fieldtype
}) })
# Добавляем поля для конкретных строк таблицы (первые 10 строк)
for row_idx in range(1, 11):
fields.append({
"fieldname": f"{child.fieldname}_{row_idx}_{sub_field.fieldname}",
"label": f"{child.label} → Строка {row_idx}{sub_field.label}",
"fieldtype": sub_field.fieldtype,
"is_row_specific": True,
"row_index": row_idx
})
return fields return fields
@frappe.whitelist() @frappe.whitelist()

View File

@ -8,6 +8,7 @@
"target_doctype", "target_doctype",
"formula_storage", "formula_storage",
"universal_fields_storage", "universal_fields_storage",
"table_row_formulas_storage",
"formula_fields", "formula_fields",
"test" "test"
], ],
@ -20,7 +21,7 @@
}, },
{ {
"fieldname": "formula_storage", "fieldname": "formula_storage",
"fieldtype": "Text", "fieldtype": "Long Text",
"label": "formula_storage" "label": "formula_storage"
}, },
{ {
@ -34,13 +35,18 @@
}, },
{ {
"fieldname": "universal_fields_storage", "fieldname": "universal_fields_storage",
"fieldtype": "Text", "fieldtype": "Long Text",
"label": "universal_fields_storage" "label": "universal_fields_storage"
},
{
"fieldname": "table_row_formulas_storage",
"fieldtype": "Long Text",
"label": "table_row_formulas_storage"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2025-03-06 13:11:19.311286", "modified": "2025-04-03 16:25:00.731153",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Formula Editor", "module": "Formula Editor",
"name": "Formula Editor", "name": "Formula Editor",