[fix] don't allow import for child tables

This commit is contained in:
Anand Doshi 2016-01-06 12:22:03 +05:30
parent cfdaf5b10a
commit 106e281608
5 changed files with 20 additions and 8 deletions

View file

@ -50,6 +50,9 @@ 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:

View file

@ -110,7 +110,8 @@ frappe.DataImportTool = Class.extend({
me.write_messages(r.messages);
}
}
},
is_private: true
});
frappe.realtime.on("data_import_progress", function(data) {

View file

@ -19,11 +19,7 @@ def get_data_keys():
@frappe.whitelist()
def get_doctypes():
if "System Manager" in frappe.get_roles():
return [r[0] for r in frappe.db.sql("""select name from `tabDocType`
where allow_import = 1""")]
else:
return frappe.get_user()._get("can_import")
return frappe.get_user()._get("can_import")
@frappe.whitelist()
def get_doctype_options():

View file

@ -372,6 +372,12 @@ class BaseDocument(object):
if self.get(df.fieldname) in (None, []) or not strip_html(cstr(self.get(df.fieldname))).strip():
missing.append((df.fieldname, get_msg(df)))
# check for missing parent and parenttype
if self.meta.istable:
for fieldname in ("parent", "parenttype"):
if not self.get(fieldname):
missing.append((fieldname, get_msg(frappe._dict(label=fieldname))))
return missing
def get_invalid_links(self, is_submittable=False):

View file

@ -1,6 +1,6 @@
{
"allow_copy": 0,
"allow_import": 1,
"allow_import": 0,
"allow_rename": 0,
"creation": "2013-02-22 01:27:36",
"custom": 0,
@ -25,6 +25,7 @@
"options": "Workflow State",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": "160px",
"read_only": 0,
"report_hide": 0,
@ -51,6 +52,7 @@
"options": "0\n1\n2",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": "80px",
"read_only": 0,
"report_hide": 0,
@ -75,6 +77,7 @@
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@ -97,6 +100,7 @@
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@ -120,6 +124,7 @@
"options": "Role",
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": "160px",
"read_only": 0,
"report_hide": 0,
@ -144,6 +149,7 @@
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"print_width": "160px",
"read_only": 0,
"report_hide": 0,
@ -163,7 +169,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2015-11-16 06:30:00.914841",
"modified": "2016-01-06 01:47:09.151971",
"modified_by": "Administrator",
"module": "Workflow",
"name": "Workflow Document State",