fix: add mandatory fields in convert to deal modal if not added
(cherry picked from commit 17fdbb05cedad890631465d1ad64fbc502dd00c9)
This commit is contained in:
parent
57fb8b3abe
commit
b1ea3edceb
@ -47,6 +47,13 @@ def get_fields_layout(doctype: str, type: str, parent_doctype: str | None = None
|
|||||||
fields = frappe.get_meta(doctype).fields
|
fields = frappe.get_meta(doctype).fields
|
||||||
fields = [field for field in fields if field.fieldname in allowed_fields]
|
fields = [field for field in fields if field.fieldname in allowed_fields]
|
||||||
|
|
||||||
|
required_fields = []
|
||||||
|
|
||||||
|
if type == "Required Fields":
|
||||||
|
required_fields = [
|
||||||
|
field for field in frappe.get_meta(doctype, False).fields if field.reqd and not field.default
|
||||||
|
]
|
||||||
|
|
||||||
for tab in tabs:
|
for tab in tabs:
|
||||||
for section in tab.get("sections"):
|
for section in tab.get("sections"):
|
||||||
if section.get("columns"):
|
if section.get("columns"):
|
||||||
@ -60,6 +67,32 @@ def get_fields_layout(doctype: str, type: str, parent_doctype: str | None = None
|
|||||||
handle_perm_level_restrictions(field, doctype, parent_doctype)
|
handle_perm_level_restrictions(field, doctype, parent_doctype)
|
||||||
column["fields"][column.get("fields").index(field["fieldname"])] = field
|
column["fields"][column.get("fields").index(field["fieldname"])] = field
|
||||||
|
|
||||||
|
# remove field from required_fields if it is already present
|
||||||
|
if (
|
||||||
|
type == "Required Fields"
|
||||||
|
and field.reqd
|
||||||
|
and any(f.get("fieldname") == field.get("fieldname") for f in required_fields)
|
||||||
|
):
|
||||||
|
required_fields = [
|
||||||
|
f for f in required_fields if f.get("fieldname") != field.get("fieldname")
|
||||||
|
]
|
||||||
|
|
||||||
|
if type == "Required Fields" and required_fields and tabs:
|
||||||
|
tabs[-1].get("sections").append(
|
||||||
|
{
|
||||||
|
"label": "Required Fields",
|
||||||
|
"name": "required_fields_section_" + str(random_string(4)),
|
||||||
|
"opened": True,
|
||||||
|
"hideLabel": True,
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"name": "required_fields_column_" + str(random_string(4)),
|
||||||
|
"fields": [field.as_dict() for field in required_fields],
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return tabs or []
|
return tabs or []
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user