From 3c7454d5c701ca9306abf89a35105672d0a2a285 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 30 Dec 2024 15:33:16 +0530 Subject: [PATCH] fix: get default field layout is not exist not returning options properly --- .../crm_fields_layout/crm_fields_layout.py | 26 ++++++++----------- .../src/components/Controls/GridRowModal.vue | 23 +--------------- frontend/src/components/FieldLayout.vue | 1 - 3 files changed, 12 insertions(+), 38 deletions(-) diff --git a/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py index 54797ba2..a20138c0 100644 --- a/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py +++ b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py @@ -46,15 +46,11 @@ def get_fields_layout(doctype: str, type: str): for field in section.get("fields") if section.get("fields") else []: field = next((f for f in fields if f.fieldname == field), None) if field: - if field.fieldtype == "Select" and field.options: - field.options = field.options.split("\n") - field.options = [{"label": _(option), "value": option} for option in field.options] - field.options.insert(0, {"label": "", "value": ""}) field = { "label": _(field.label), "name": field.fieldname, "type": field.fieldtype, - "options": field.options, + "options": getOptions(field), "mandatory": field.reqd, "placeholder": field.get("placeholder"), "filters": field.get("link_filters"), @@ -86,17 +82,17 @@ def save_fields_layout(doctype: str, type: str, layout: str): def get_default_layout(doctype: str): fields = frappe.get_meta(doctype).fields fields = [ - { - "label": _(field.label), - "name": field.fieldname, - "type": field.fieldtype, - "options": field.options, - "mandatory": field.reqd, - "placeholder": field.get("placeholder"), - "filters": field.get("link_filters"), - } + field.fieldname for field in fields - if field.fieldtype not in ["Section Break", "Column Break"] + if field.fieldtype not in ["Tab Break", "Section Break", "Column Break"] ] return [{"no_tabs": True, "sections": [{"hideLabel": True, "fields": fields}]}] + + +def getOptions(field): + if field.fieldtype == "Select" and field.options: + field.options = field.options.split("\n") + field.options = [{"label": _(option), "value": option} for option in field.options] + field.options.insert(0, {"label": "", "value": ""}) + return field.options diff --git a/frontend/src/components/Controls/GridRowModal.vue b/frontend/src/components/Controls/GridRowModal.vue index 91ad60c0..93351b4e 100644 --- a/frontend/src/components/Controls/GridRowModal.vue +++ b/frontend/src/components/Controls/GridRowModal.vue @@ -33,7 +33,6 @@