From ca57329cbd139ce745d6f92a3ee33e751cd61344 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 18 Aug 2014 12:59:28 +0530 Subject: [PATCH] Fixes for Fold fieldtype --- frappe/core/doctype/doctype/doctype.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index a5326199e5..8032577370 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -235,10 +235,13 @@ def validate_fields(fields): if fold_exists: frappe.throw(_("There can be only one Fold in a form")) fold_exists = True - nxt = fields[i+1] - if nxt.fieldtype != "Section Break" \ - or (nxt.fieldtype=="Section Break" and not nxt.label): - frappe.throw(_("Fold must come before a labelled Section Break")) + if i < len(fields)-1: + nxt = fields[i+1] + if nxt.fieldtype != "Section Break" \ + or (nxt.fieldtype=="Section Break" and not nxt.label): + frappe.throw(_("Fold must come before a labelled Section Break")) + else: + frappe.throw(_("Fold can not be at the end of the form")) for d in fields: if not d.permlevel: d.permlevel = 0