diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index e150e84a9e..6bffb42cd3 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -37,6 +37,15 @@ class DocType(Document): for c in [".", "/", "#", "&", "=", ":", "'", '"']: if c in self.name: frappe.throw(_("{0} not allowed in name").format(c)) + + if self.issingle: + self.allow_import = 0 + self.is_submittable = 0 + self.istable = 0 + + elif self.istable: + self.allow_import = 0 + self.validate_series() self.scrub_field_names() self.validate_document_type() @@ -50,9 +59,6 @@ class DocType(Document): self.make_amendable() - if self.istable: - self.allow_import = 0 - def check_developer_mode(self): """Throw exception if not developer mode or via patch""" if frappe.flags.in_patch: @@ -298,6 +304,10 @@ def validate_fields(meta): frappe.throw(_("Precision should be between 1 and 6")) def check_unique_and_text(d): + if meta.issingle: + d.unique = 0 + d.search_index = 0 + if getattr(d, "unique", False): if d.fieldtype not in ("Data", "Link", "Read Only"): frappe.throw(_("Fieldtype {0} for {1} cannot be unique").format(d.fieldtype, d.label)) diff --git a/frappe/public/js/frappe/form/control.js b/frappe/public/js/frappe/form/control.js index 7c6e627f9d..5b5e93571f 100644 --- a/frappe/public/js/frappe/form/control.js +++ b/frappe/public/js/frappe/form/control.js @@ -672,7 +672,14 @@ frappe.ui.form.ControlCheck = frappe.ui.form.ControlData.extend({ set_input: function(value) { this.input.checked = value ? 1 : 0; this.last_value = value; - } + }, + get_value: function() { + if (!this.$input) { + return; + } + + return this.$input.prop("checked") ? 1 : 0; + }, }); frappe.ui.form.ControlButton = frappe.ui.form.ControlData.extend({