fix(minor): default check value to 0 and validate

This commit is contained in:
Rushabh Mehta 2019-05-16 15:00:14 +05:30
parent b19f84120c
commit e5b97de255
2 changed files with 5 additions and 2 deletions

View file

@ -413,6 +413,7 @@
"options": "InnoDB\nMyISAM"
},
{
"default": "0",
"fieldname": "show_preview_popup",
"fieldtype": "Check",
"label": "Show Preview Popup"
@ -420,7 +421,7 @@
],
"icon": "fa fa-bolt",
"idx": 6,
"modified": "2019-05-16 09:18:29.373576",
"modified": "2019-05-16 14:58:33.405381",
"modified_by": "Administrator",
"module": "Core",
"name": "DocType",

View file

@ -616,7 +616,9 @@ def validate_fields(meta):
frappe.throw(_("Options 'Dynamic Link' type of field must point to another Link Field with options as 'DocType'"))
def check_illegal_default(d):
if d.fieldtype == "Check" and d.default and d.default not in ('0', '1'):
if d.fieldtype == "Check" and not d.default:
d.default = '0'
if d.fieldtype == "Check" and d.default not in ('0', '1'):
frappe.throw(_("Default for 'Check' type of field must be either '0' or '1'"))
if d.fieldtype == "Select" and d.default and (d.default not in d.options.split("\n")):
frappe.throw(_("Default for {0} must be an option").format(d.fieldname))