From 493d942e486473762c035ff22c84c5070522ea3b Mon Sep 17 00:00:00 2001
From: root
Date: Tue, 2 Apr 2019 18:28:07 +0200
Subject: [PATCH] Version 1.1.0
---
pibiapp/config/desktop.py | 10 +-
pibiapp/config/external_data.py | 5 +
pibiapp/config/redash.py | 26 +
pibiapp/config/xlsdata.py | 16 -
pibiapp/external_data/data_manage.py | 201 ++-
.../doctype/change_docfield/__init__.py | 0
.../change_docfield/change_docfield.json | 1598 +++++++++++++++++
.../change_docfield/change_docfield.py | 10 +
.../doctype/change_doctype_empty/__init__.py | 0
.../change_doctype_empty.js | 26 +
.../change_doctype_empty.json | 246 +++
.../change_doctype_empty.py | 24 +
.../test_change_doctype_empty.py | 10 +
.../doctype/conversion_rules/__init__.py | 0
.../conversion_rules/conversion_rules.js | 107 ++
.../conversion_rules/conversion_rules.json | 507 ++++++
.../conversion_rules/conversion_rules.py | 10 +
.../conversion_rules/test_conversion_rules.py | 10 +
.../ext_data_source/ext_data_source.js | 15 +-
pibiapp/hooks.py | 13 +
pibiapp/modules.txt | 1 +
.../nextcloud_settings/nextcloud_settings.js | 13 +-
.../nextcloud_settings.json | 200 ++-
.../nextcloud_settings/nextcloud_settings.py | 137 +-
pibiapp/nextcloud/nextcloud_link.py | 30 +-
pibiapp/redash/__init__.py | 0
pibiapp/redash/doctype/__init__.py | 0
.../redash_business_intelligence/__init__.py | 0
.../redash_business_intelligence.js | 28 +
.../redash_business_intelligence.json | 134 ++
.../redash_business_intelligence.py | 25 +
.../test_redash_business_intelligence.py | 10 +
.../doctype/redash_dashboards/__init__.py | 0
.../redash_dashboards/redash_dashboards.js | 8 +
.../redash_dashboards/redash_dashboards.json | 211 +++
.../redash_dashboards/redash_dashboards.py | 10 +
.../test_redash_dashboards.py | 10 +
pibiapp/redash/doctype/redashperm/__init__.py | 0
.../redash/doctype/redashperm/redashperm.json | 76 +
.../redash/doctype/redashperm/redashperm.py | 10 +
40 files changed, 3697 insertions(+), 40 deletions(-)
create mode 100644 pibiapp/config/redash.py
delete mode 100755 pibiapp/config/xlsdata.py
create mode 100644 pibiapp/external_data/doctype/change_docfield/__init__.py
create mode 100644 pibiapp/external_data/doctype/change_docfield/change_docfield.json
create mode 100644 pibiapp/external_data/doctype/change_docfield/change_docfield.py
create mode 100644 pibiapp/external_data/doctype/change_doctype_empty/__init__.py
create mode 100644 pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.js
create mode 100644 pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.json
create mode 100644 pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.py
create mode 100644 pibiapp/external_data/doctype/change_doctype_empty/test_change_doctype_empty.py
create mode 100644 pibiapp/external_data/doctype/conversion_rules/__init__.py
create mode 100644 pibiapp/external_data/doctype/conversion_rules/conversion_rules.js
create mode 100644 pibiapp/external_data/doctype/conversion_rules/conversion_rules.json
create mode 100644 pibiapp/external_data/doctype/conversion_rules/conversion_rules.py
create mode 100644 pibiapp/external_data/doctype/conversion_rules/test_conversion_rules.py
create mode 100644 pibiapp/redash/__init__.py
create mode 100644 pibiapp/redash/doctype/__init__.py
create mode 100644 pibiapp/redash/doctype/redash_business_intelligence/__init__.py
create mode 100644 pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.js
create mode 100644 pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.json
create mode 100644 pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.py
create mode 100644 pibiapp/redash/doctype/redash_business_intelligence/test_redash_business_intelligence.py
create mode 100644 pibiapp/redash/doctype/redash_dashboards/__init__.py
create mode 100644 pibiapp/redash/doctype/redash_dashboards/redash_dashboards.js
create mode 100644 pibiapp/redash/doctype/redash_dashboards/redash_dashboards.json
create mode 100644 pibiapp/redash/doctype/redash_dashboards/redash_dashboards.py
create mode 100644 pibiapp/redash/doctype/redash_dashboards/test_redash_dashboards.py
create mode 100644 pibiapp/redash/doctype/redashperm/__init__.py
create mode 100644 pibiapp/redash/doctype/redashperm/redashperm.json
create mode 100644 pibiapp/redash/doctype/redashperm/redashperm.py
diff --git a/pibiapp/config/desktop.py b/pibiapp/config/desktop.py
index b2ea397..a36f172 100755
--- a/pibiapp/config/desktop.py
+++ b/pibiapp/config/desktop.py
@@ -19,5 +19,13 @@ def get_data():
"type": "module",
"label": _("External Data"),
"hidden": 1
- }
+ },
+ {
+ "module_name": "Redash",
+ "color": "grey",
+ "icon": "octicon octicon-pulse",
+ "type": "module",
+ "label": _("Redash"),
+ "hidden": 1
+ }
]
diff --git a/pibiapp/config/external_data.py b/pibiapp/config/external_data.py
index f0307bc..29c0405 100644
--- a/pibiapp/config/external_data.py
+++ b/pibiapp/config/external_data.py
@@ -11,6 +11,11 @@ def get_data():
"name": "Ext Data Source",
"description": _("Load files as new doctype of Frappe"),
},
+ {
+ "type": "doctype",
+ "name": "Change DocType Empty",
+ "description": _("Change the fields of an external data DocType while it is empty"),
+ },
{
"type": "doctype",
"name": "Successive loads",
diff --git a/pibiapp/config/redash.py b/pibiapp/config/redash.py
new file mode 100644
index 0000000..565b74a
--- /dev/null
+++ b/pibiapp/config/redash.py
@@ -0,0 +1,26 @@
+from __future__ import unicode_literals
+from frappe import _
+
+def get_data():
+ return [
+ {
+ "label": _("Dashboards"),
+ "items": [
+ {
+ "type": "doctype",
+ "name": "Redash Business Intelligence",
+ "description": _("It shows the dashboards designed in Redash and enabled in Frappe"),
+ }
+ ]
+ },
+ {
+ "label": _("Settings"),
+ "items": [
+ {
+ "type": "doctype",
+ "name": "Redash Dashboards",
+ "description": _("List of dashboards and viewing permissions"),
+ }
+ ]
+ }
+]
diff --git a/pibiapp/config/xlsdata.py b/pibiapp/config/xlsdata.py
deleted file mode 100755
index 3d5e6c1..0000000
--- a/pibiapp/config/xlsdata.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from __future__ import unicode_literals
-from frappe import _
-
-def get_data():
- return [
- {
- "label": _("Settings"),
- "items": [
- {
- "type": "doctype",
- "name": "Xls File to Load",
- "description": _("Load Excel files as new doctype of Frappe"),
- }
- ]
- }
-]
diff --git a/pibiapp/external_data/data_manage.py b/pibiapp/external_data/data_manage.py
index 01a686e..69554c8 100644
--- a/pibiapp/external_data/data_manage.py
+++ b/pibiapp/external_data/data_manage.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
# Copyright (c) 2019, Dolores Juliana Fdez Martin
# License: GNU General Public License v3. See license.txt
#
@@ -18,11 +19,22 @@
from __future__ import unicode_literals
import frappe, ast
+from frappe import _
from frappe.utils.xlsxutils import read_xlsx_file_from_attached_file
from frappe.utils.csvutils import read_csv_content
import six
+from six import text_type, string_types
from datetime import date, datetime
+from frappe.utils import nowdate
+from frappe.utils.dateutils import parse_date
+from frappe.utils import cint, cstr, flt, getdate, get_datetime, get_url, get_url_to_form
from xml.etree import ElementTree as ET
+import copy
+
+def force_to_unicode(text):
+ if text == None: text = " "
+ resp = text.encode('ascii', 'ignore').decode('ascii')
+ return resp
def loaddata(self, method=None):
ext_rows = readfile(file_url=self.import_file, data_format=self.data_format)
@@ -36,7 +48,7 @@ def loaddata(self, method=None):
numrecords = addrecords(name=self.name, datarows=datarows)
message = str(numrecords) + ' records loaded in the DocType ' + self.name
frappe.publish_realtime('msgprint', message )
-
+
def reloaddata(self, method=None):
ext_rows = readfile(file_url=self.import_file, data_format=self.data_format)
row_stop = 0 if self.row_end == 0 else self.row_start + self.row_end - 1
@@ -105,6 +117,8 @@ def analyzedata(row_labels, row_start, ext_rows, row_stop=None, newdata=False, n
xrow = 0
tt = []
labels = []
+ tmp_list = []
+ fields = []
lengths = []
datatypes = []
datamandatory = []
@@ -117,19 +131,36 @@ def analyzedata(row_labels, row_start, ext_rows, row_stop=None, newdata=False, n
continue
if row_stop and row_stop > 0 and xrow > row_stop:
break
+ # Row empty?
+ if columns > 0:
+ rowempty = 1
+ i = 0
+ for cell in row:
+ if i >= columns: break
+ if cell and str(cell).strip() != "":
+ rowempty = 0
+ break
+ i += 1
+ if rowempty == 1: continue
+
tmp_list = []
i = 0
for cell in row:
+ # Label empty END
+ if columns == 0 and (cell == None or cell == ""): break
+ if columns > 0 and i >= columns: break
+
if isinstance(cell, six.string_types):
if columns == 0:
- tmp_list.append(cell.replace('"',''))
+ tmp_list.append(cell.replace('"','').replace('.','').replace(',',''))
else: tmp_list.append(cell.strip().replace('"','').encode('utf8'))
- else: tmp_list.append(cell)
+ else:
+ tmp_list.append(cell)
if newdata and columns > 0 and i <= columns :
x = 0
if isinstance(cell, six.string_types): x = len(cell)
lengths[i] = max( x, lengths[i])
- if datatypes[i] == "Data":
+ if datatypes[i] == "PTE":
if lengths[i] > 140:
datatypes[i] = "Small Text"
else:
@@ -138,32 +169,49 @@ def analyzedata(row_labels, row_start, ext_rows, row_stop=None, newdata=False, n
if isinstance(cell, float): datatypes[i] = "Float"
if isinstance(cell, datetime): datatypes[i] = "Datetime"
if isinstance(cell, date): datatypes[i] = "Date"
+ if isinstance(cell, str): datatypes[i] = "Data"
else:
if cell and cell != "" and cell != None and cell != 0 and cell != "0":
+ if lengths[i] > 140: datatypes[i] = "Small Text"
if datatypes[i] == "Int" and not isinstance(cell, int) and not isinstance(cell, long): datatypes[i] = "Data"
if datatypes[i] == "Float" and not isinstance(cell, float): datatypes[i] = "Data"
if datatypes[i] == "Date" and not isinstance(cell, date): datatypes[i] = "Data"
if datatypes[i] == "Datetime" and not isinstance(cell, datetime): datatypes[i] = "Data"
if not cell or cell == "" or cell == None:
if datamandatory[i] == 1: datamandatory[i] = 0
- if datatypes[i] == "Data" and datamandatory[i] == 1:
+ if datatypes[i] == "Data" and datamandatory[i] == 1 and isinstance(cell, str):
if not cell.strip() in datavalues[i]:
datavalues[i].append(cell.strip())
i += 1
if xrow == row_labels:
- labels = tmp_list
- columns = len(labels)
fields = tmp_list
+ columns = len(tmp_list)
+ labels = copy.deepcopy(tmp_list)
i = 1
while i <= columns :
lengths.append(0)
- datatypes.append("Data")
+ datatypes.append("PTE")
datamandatory.append(1)
datavalues.append([])
j = i - 1
+ labels[j] = force_to_unicode(labels[j])
+ fields[j] = force_to_unicode(fields[j])
fields[j] = str(fields[j]).lower().replace(" ", "_")
+ if fields[j] == "_":
+ fields[j] = "column_" + str(i)
+ labels[j] = "Column " + str(i)
i += 1
datarows.append(fields)
+ # template diferent
+ if not newdata:
+ meta = frappe.get_meta(name)
+ i = 1
+ while i <= columns :
+ j = i - 1
+ df = meta.get_field(fields[j])
+ if not df:
+ frappe.throw(_("The fields of the file you are trying to load do not correspond to the fields in the initial template file"))
+ i += 1
else:
datarows.append(tmp_list)
if newdata:
@@ -177,6 +225,7 @@ def analyzedata(row_labels, row_start, ext_rows, row_stop=None, newdata=False, n
datavalues[i] = listdv
else:
datavalues[i] = ""
+ if datatypes[i] == "PTE": datatypes[i] = "Data"
i += 1
adddoctype(name, module, fields, labels, datatypes, datamandatory, datavalues)
return datarows
@@ -189,6 +238,7 @@ def adddoctype(name, module, fields, labels, datatypes, datamandatory, datavalue
"name": name,
"quick_entry": 0,
"custom": 1 })
+
i = 0
for cell in labels:
doc_field = frappe.get_doc({
@@ -203,6 +253,19 @@ def adddoctype(name, module, fields, labels, datatypes, datamandatory, datavalue
"in_list_view": 1 if i < 3 else 0})
doc.append ("fields", doc_field)
i += 1
+
+ doc_field = frappe.get_doc({
+ "doctype": "DocField",
+ "label": "Row Original",
+ "fieldtype": "Text Editor",
+ "fieldname": "row_original",
+ "reqd": 0,
+ "in_standard_filter": 0,
+ "search_index": 0,
+ "options": "",
+ "in_list_view": 0,
+ "hidden": 1})
+ doc.append ("fields", doc_field)
if roles == None:
roles = ["System Manager", "Administrator"]
@@ -214,7 +277,9 @@ def adddoctype(name, module, fields, labels, datatypes, datamandatory, datavalue
doc.insert(ignore_permissions=True)
def addrecords(name, datarows, limit=65000):
+ meta = frappe.get_meta(name)
columns = 0
+ x = 0
j = 0
for row in datarows:
if j >= limit: break
@@ -226,10 +291,126 @@ def addrecords(name, datarows, limit=65000):
i = 0
for cell in row:
if i >= columns: break
+ df = meta.get_field(fields[i])
+ fieldtype = df.fieldtype if df else "Data"
+ if fieldtype in ("Int", "Check"):
+ cell = cint(cell)
+ elif fieldtype in ("Float", "Currency", "Percent"):
+ cell = flt(cell)
+ elif fieldtype == "Date":
+ if cell and isinstance(cell, datetime):
+ cell = str(cell)
+ if cell and isinstance(cell, string_types):
+ cell = getdate(parse_date(cell))
+ elif fieldtype == "Datetime":
+ if cell:
+ if " " in cell:
+ _date, _time = cell.split()
+ else:
+ _date, _time = cell, '00:00:00'
+ _date = parse_date(cell)
+ cell = get_datetime(_date + " " + _time)
+ else:
+ cell = None
+ elif fieldtype in ("Link", "Dynamic Link", "Data") and cell:
+ cell = cstr(cell)
+
datadoc.setdefault(fields[i], cell)
i += 1
+
+ row_original = str(datadoc)
+ xduplicates = frappe.get_list(name, filters={'row_original': row_original}, fields=['name'])
+ j += 1
+ if len(xduplicates) > 0:
+ x += 1
+ continue
+ datadoc = conversionrules(datadoc)
+ datadoc.setdefault("row_original", row_original)
doc = frappe.get_doc(datadoc)
doc.insert(ignore_permissions=True)
- j += 1
- return j
+ return j - x
+
+def conversionrules(doc, conversion_type='During loading'):
+ rules = frappe.get_all("Conversion Rules",
+ filters={"reference_doctype": doc['doctype'], "conversion_type": conversion_type},
+ fields=["origin_field", "action", "receiver_field"],
+ order_by = 'execution_order')
+ for rule in rules:
+ x = doc.get(rule.origin_field)
+ y = executeaction(x, rule.action)
+ if doc[rule.receiver_field]: doc[rule.receiver_field] = y
+ else: doc.setdefault(rule.receiver_field, y)
+ return doc
+
+def executeaction(x, action, param1=None, param2=None):
+ if not x or x == None: return x
+ xact = ['Convert to Uppercase','Convert to Lowercase','Convert First Letter to Uppercase',
+ 'Remove White Character from Beginning and End','Replace character or string (All)',
+ 'Replace character or string (the First one)','Replace character or string (the Last one)']
+ i = xact.index(action)
+ if i == 0: return x.upper()
+ if i == 1: return x.lower()
+ if i == 2: return (x[0].upper() + x[1:].lower())
+ if i == 3: return x.strip()
+ if i == 4 and param1 != None and param2 != None: return x.replace(param1, param2)
+ if i == 5 and param1 != None and param2 != None: return x.replace(param1, param2, 1)
+
+ return x
+def changedoctype(self, method=None):
+ if not frappe.db.exists('DocType', self.reference_doctype):
+ return
+ if not frappe.db.table_exists(self.name) and not self.docfield:
+ return
+ allfields = frappe.get_list('Change DocField', filters={'parent': self.name}, fields="*")
+ keydata = ["label","fieldtype","reqd","search_index","in_list_view","in_standard_filter","options","default","length","in_global_search","allow_in_quick_entry","bold","description"]
+ for onefield in allfields:
+ docname = frappe.get_list('DocField',
+ filters={'parent': self.reference_doctype, 'fieldname': onefield.fieldname },
+ fields=["name"])
+ doc = frappe.get_doc('DocField', docname[0]['name'])
+ for onekey in keydata:
+ if doc.get(onekey) != onefield.get(onekey):
+ setattr(doc,onekey,onefield.get(onekey))
+ doc.save()
+
+def doctype_query(doctype, txt, searchfield, start, page_len, filters, as_dict=False):
+ return frappe.db.sql("""select eds.name
+ from `tabExt Data Source` eds
+ INNER JOIN tabDocType dt on eds.name = dt.name
+ """,{
+ "today": nowdate(),
+ "txt": "%%%s%%" % txt,
+ "_txt": txt.replace("%", ""),
+ "start": start,
+ "page_len": page_len
+ }, as_dict=as_dict)
+
+@frappe.whitelist()
+def deletedata(doctype):
+ numrecords = frappe.db.count(doctype)
+ if not numrecords or numrecords == 0:
+ frappe.throw(_("{0} is empty contains {1} records.").format(doctype,numrecords))
+ if not frappe.db.exists('DocType', doctype):
+ frappe.throw(_("{0} is not a doctype of the database.").format(doctype))
+ if not frappe.db.exists('Ext Data Source', doctype):
+ frappe.throw(_("{0} is not a External Data.").format(doctype))
+
+ il = frappe.get_all(doctype, fields=['name'])
+ failed = []
+ i = 0
+ for dd in il:
+ d = dd.name
+ try:
+ frappe.delete_doc(doctype, d)
+ if numrecords >= 5:
+ frappe.publish_realtime("progress",
+ dict(progress=[i+1, numrecords], title=_('Deleting {0}').format(doctype), description=d),
+ user=frappe.session.user)
+ i += 1
+ except Exception:
+ failed.append(d)
+
+ message = str(numrecords - len(failed)) + ' records loaded in the DocType ' + doctype
+ frappe.publish_realtime('msgprint', message )
+ return failed
diff --git a/pibiapp/external_data/doctype/change_docfield/__init__.py b/pibiapp/external_data/doctype/change_docfield/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pibiapp/external_data/doctype/change_docfield/change_docfield.json b/pibiapp/external_data/doctype/change_docfield/change_docfield.json
new file mode 100644
index 0000000..7abbefc
--- /dev/null
+++ b/pibiapp/external_data/doctype/change_docfield/change_docfield.json
@@ -0,0 +1,1598 @@
+{
+ "allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "autoname": "hash",
+ "beta": 0,
+ "creation": "2019-03-21 07:58:28.703031",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "Setup",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "label_and_type",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 1,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "label",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Label",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "label",
+ "oldfieldtype": "Data",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "163",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 1,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "163"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 1,
+ "collapsible": 0,
+ "columns": 0,
+ "default": "Data",
+ "fieldname": "fieldtype",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Type",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "fieldtype",
+ "oldfieldtype": "Select",
+ "options": "Check\nCurrency\nData\nDate\nDatetime\nFloat\nInt\nLong Text\nSelect\nSmall Text\nTime",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 1,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 1,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "fieldname",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Name",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "fieldname",
+ "oldfieldtype": "Data",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 1,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "reqd",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Mandatory",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "reqd",
+ "oldfieldtype": "Check",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "50px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "50px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:in_list([\"Float\", \"Currency\", \"Percent\"], doc.fieldtype)",
+ "description": "Set non-standard precision for a Float or Currency field",
+ "fieldname": "precision",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Precision",
+ "length": 0,
+ "no_copy": 0,
+ "options": "\n1\n2\n3\n4\n5\n6\n7\n8\n9",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 1,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:in_list(['Data', 'Link', 'Dynamic Link', 'Password', 'Select', 'Read Only', 'Attach', 'Attach Image', 'Int'], doc.fieldtype)",
+ "fieldname": "length",
+ "fieldtype": "Int",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Length",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "search_index",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Index",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "search_index",
+ "oldfieldtype": "Check",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "50px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "50px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "in_list_view",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "In List View",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "70px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "70px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "in_standard_filter",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "In Standard Filter",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:([\"Data\", \"Select\", \"Table\", \"Text\", \"Text Editor\", \"Link\", \"Small Text\", \"Long Text\", \"Read Only\", \"Heading\", \"Dynamic Link\"].indexOf(doc.fieldtype) !== -1)",
+ "fieldname": "in_global_search",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "In Global Search",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "allow_in_quick_entry",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Allow in Quick Entry",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "bold",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Bold",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "default": "0",
+ "depends_on": "eval:['Data', 'Select', 'Text', 'Small Text', 'Text Editor'].includes(doc.fieldtype)",
+ "fieldname": "translatable",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Translatable",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:doc.fieldtype===\"Section Break\"",
+ "fieldname": "collapsible",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Collapsible",
+ "length": 255,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:doc.fieldtype==\"Section Break\"",
+ "fieldname": "collapsible_depends_on",
+ "fieldtype": "Code",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Collapsible Depends On",
+ "length": 0,
+ "no_copy": 0,
+ "options": "JS",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_6",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:['Select'].includes(doc.fieldtype)",
+ "description": "For Links, enter the DocType as range.\nFor Select, enter list of Options, each on a new line.",
+ "fieldname": "options",
+ "fieldtype": "Small Text",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Options",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "options",
+ "oldfieldtype": "Text",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "default",
+ "fieldtype": "Small Text",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Default",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "default",
+ "oldfieldtype": "Text",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "fetch_from",
+ "fieldtype": "Small Text",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Fetch From",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "permissions",
+ "fieldtype": "Section Break",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Permissions",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "depends_on",
+ "fieldtype": "Code",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Display Depends On",
+ "length": 255,
+ "no_copy": 0,
+ "oldfieldname": "depends_on",
+ "oldfieldtype": "Data",
+ "options": "JS",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "hidden",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Hidden",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "hidden",
+ "oldfieldtype": "Check",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "50px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "50px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "read_only",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Read Only",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "50px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "50px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "unique",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Unique",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "description": "Do not allow user to change after set the first time",
+ "fieldname": "set_only_once",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Set Only Once",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval: doc.fieldtype == \"Table\"",
+ "fieldname": "allow_bulk_edit",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Allow Bulk Edit",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_13",
+ "fieldtype": "Column Break",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "default": "0",
+ "fieldname": "permlevel",
+ "fieldtype": "Int",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Perm Level",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "permlevel",
+ "oldfieldtype": "Int",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "50px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "50px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "description": "User permissions should not apply for this Link",
+ "fieldname": "ignore_user_permissions",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Ignore User Permissions",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval: parent.is_submittable",
+ "fieldname": "allow_on_submit",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Allow on Submit",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "allow_on_submit",
+ "oldfieldtype": "Check",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "50px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "50px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "report_hide",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Report Hide",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "report_hide",
+ "oldfieldtype": "Check",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "50px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "50px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:(doc.fieldtype == 'Link')",
+ "fieldname": "remember_last_selected_value",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Remember Last Selected Value",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "description": "Don't HTML Encode HTML tags like <script> or just characters like < or >, as they could be intentionally used in this field",
+ "fieldname": "ignore_xss_filter",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Ignore XSS Filter",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "display",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Display",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "in_filter",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "In Filter",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "in_filter",
+ "oldfieldtype": "Check",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "50px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "50px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "no_copy",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "No Copy",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "no_copy",
+ "oldfieldtype": "Check",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "50px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "50px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "print_hide",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Print Hide",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "print_hide",
+ "oldfieldtype": "Check",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "50px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "50px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:[\"Int\", \"Float\", \"Currency\", \"Percent\"].indexOf(doc.fieldtype)!==-1",
+ "fieldname": "print_hide_if_no_value",
+ "fieldtype": "Check",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Print Hide If No Value",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "print_width",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Print Width",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "width",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Width",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "width",
+ "oldfieldtype": "Data",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "50px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "50px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "",
+ "description": "Number of columns for a field in a List View or a Grid (Total Columns should be less than 11)",
+ "fieldname": "columns",
+ "fieldtype": "Int",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Columns",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_22",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "description",
+ "fieldtype": "Small Text",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Description",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "description",
+ "oldfieldtype": "Text",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "print_width": "300px",
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "300px"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "oldfieldname",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "oldfieldtype",
+ "fieldtype": "Data",
+ "hidden": 1,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "max_attachments": 0,
+ "modified": "2019-03-23 20:23:58.876678",
+ "modified_by": "Administrator",
+ "module": "External Data",
+ "name": "Change DocField",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "ASC",
+ "track_changes": 0,
+ "track_seen": 0,
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/pibiapp/external_data/doctype/change_docfield/change_docfield.py b/pibiapp/external_data/doctype/change_docfield/change_docfield.py
new file mode 100644
index 0000000..fba3a3e
--- /dev/null
+++ b/pibiapp/external_data/doctype/change_docfield/change_docfield.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Dolores Juliana and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class ChangeDocField(Document):
+ pass
diff --git a/pibiapp/external_data/doctype/change_doctype_empty/__init__.py b/pibiapp/external_data/doctype/change_doctype_empty/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.js b/pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.js
new file mode 100644
index 0000000..956749c
--- /dev/null
+++ b/pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.js
@@ -0,0 +1,26 @@
+// Copyright (c) 2019, Dolores Juliana and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Change DocType Empty', {
+ setup: function(frm) {
+ frm.set_query("reference_doctype", function() {
+ return{
+ query: "pibiapp.external_data.data_manage.doctype_query"
+ };
+ });
+ },
+ refresh: function(frm) {
+ var i;
+ var x = document.querySelectorAll('button.btn.btn-xs.btn-default.grid-add-row');
+ for (i = 0; i < x.length; i++) { x[i].style.display = 'none'; }
+ x = document.querySelectorAll('button.btn.btn-xs.btn-danger.grid-remove-rows');
+ for (i = 0; i < x.length; i++) {
+ x[i].style.display = 'none';
+ x[i].disabled = true;
+ }
+ x = document.querySelectorAll('button.btn.btn-default.btn-xs.pull-right.grid-insert-row');
+ for (i = 0; i < x.length; i++) {
+ x[i].remove();
+ }
+ }
+});
diff --git a/pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.json b/pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.json
new file mode 100644
index 0000000..717df62
--- /dev/null
+++ b/pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.json
@@ -0,0 +1,246 @@
+{
+ "allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2019-03-20 11:22:20.464210",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "description": "Enter the name of the external data source that you want to modify. After saving it will show the current situation of that data model and may propose changes, to make them effective you must save and submit.\n",
+ "fieldname": "section_break_1",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "description": "You can empty the DocType by executing the menu option \"Clean Data Loaded\" in External Data > Ext Data Source ",
+ "fieldname": "reference_doctype",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 1,
+ "label": "DocType",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Ext Data Source",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 1,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:(!doc.__islocal)",
+ "description": "Warning: You should not change the labels of your template, these should correspond to the names of the fields of the external data model, otherwise the external data file will not be loaded.",
+ "fieldname": "section_break_2",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "docfield",
+ "fieldtype": "Table",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Field",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Change DocField",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "amended_from",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Amended From",
+ "length": 0,
+ "no_copy": 1,
+ "options": "Change DocType Empty",
+ "permlevel": 0,
+ "print_hide": 1,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 1,
+ "issingle": 0,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2019-03-24 09:33:43.515764",
+ "modified_by": "Administrator",
+ "module": "External Data",
+ "name": "Change DocType Empty",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "System Manager",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Administrator",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ }
+ ],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0,
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.py b/pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.py
new file mode 100644
index 0000000..351a739
--- /dev/null
+++ b/pibiapp/external_data/doctype/change_doctype_empty/change_doctype_empty.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*- Copyright (c) 2019, Dolores Juliana and contributors For license information, please see
+# license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+from frappe import _
+
+class ChangeDocTypeEmpty(Document):
+ def validate(self):
+ numrecords = frappe.db.count(self.reference_doctype)
+ if numrecords and numrecords > 0:
+ frappe.throw(_("{0} is not empty contains {1} records. You can not make changes until you empty it.").format(self.reference_doctype,numrecords))
+
+ if not frappe.db.table_exists(self.name) and not self.docfield:
+ allfields = frappe.get_list('DocField', filters={'parent': self.reference_doctype}, fields="*")
+ for onefield in allfields:
+ datadoc = onefield
+ #frappe.throw((self.name + " -> " + str(datadoc)))
+ datadoc['doctype'] = 'Change DocField'
+ datadoc['parent'] = self.name
+ del datadoc['name']
+ doc = frappe.get_doc(datadoc)
+ self.append ("docfield", doc)
diff --git a/pibiapp/external_data/doctype/change_doctype_empty/test_change_doctype_empty.py b/pibiapp/external_data/doctype/change_doctype_empty/test_change_doctype_empty.py
new file mode 100644
index 0000000..98a3088
--- /dev/null
+++ b/pibiapp/external_data/doctype/change_doctype_empty/test_change_doctype_empty.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Dolores Juliana and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestChangeDocTypeEmpty(unittest.TestCase):
+ pass
diff --git a/pibiapp/external_data/doctype/conversion_rules/__init__.py b/pibiapp/external_data/doctype/conversion_rules/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pibiapp/external_data/doctype/conversion_rules/conversion_rules.js b/pibiapp/external_data/doctype/conversion_rules/conversion_rules.js
new file mode 100644
index 0000000..4e6a529
--- /dev/null
+++ b/pibiapp/external_data/doctype/conversion_rules/conversion_rules.js
@@ -0,0 +1,107 @@
+// Copyright (c) 2019, Dolores Juliana and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Conversion Rules', {
+ setup: function(frm) {
+ frm.set_query("reference_doctype", function() {
+ return{
+ query: "pibiapp.external_data.data_manage.doctype_query"
+ };
+ });
+ },
+ reference_doctype: function(frm) {
+ if(!frm.doc.reference_doctype) return;
+
+ frappe.model.with_doctype(frm.doc.reference_doctype, function() {
+ var options = $.map(frappe.get_meta(frm.doc.reference_doctype).fields,
+ function(d) {
+ if(d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype)===-1) {
+ return d.fieldname;
+ }
+ return null;
+ }
+ );
+ frm.set_df_property('origin_field', 'options', options);
+ frm.set_df_property('field_for_action', 'options', options);
+ });
+ var nn = 10;
+ frm.set_value('execution_order', nn);
+ frappe.model.get_value('Conversion Rules', {'reference_doctype': frm.doc.reference_doctype}, 'execution_order', function(d) {
+ nn = d.execution_order;
+ nn += 10;
+ frm.set_value('execution_order', nn);
+ });
+ refresh_field('execution_order');
+ },
+ origin_field: function(frm) {
+ if(!frm.doc.origin_field) return;
+ var cact = ['Convert to Uppercase','Convert to Lowercase','Convert First Letter to Uppercase',
+ 'Remove White Character from Beginning and End','Replace character or string (All)',
+ 'Replace character or string (the First one)','Replace character or string (the Last one)',
+ 'If it is empty fill with a fixed value','Add a fixed value at the start',
+ 'Add a fixed value at the end','Concatenate another field at the beginning',
+ 'Concatenate another field at the end'];
+ frappe.model.with_doctype(frm.doc.reference_doctype, function() {
+ var options = $.map(frappe.get_meta(frm.doc.reference_doctype).fields,
+ function(d) {
+ if(d.fieldname && d.fieldname==frm.doc.origin_field) {
+ return d.fieldtype;
+ }
+ return null;
+ }
+ );
+ frm.set_value('type', options[0]);
+ refresh_field('type');
+ });
+ var xact = [];
+ if(frm.doc.type != 'Int' && frm.doc.type != 'Float') {
+ xact = cact;
+ }
+ frm.set_df_property('action', 'options', xact);
+ frm.set_df_property('receiver_field', 'options', [frm.doc.origin_field, 'Create new field']);
+ frm.set_value('receiver_field', frm.doc.origin_field);
+ },
+ refresh: function(frm) {
+ var cact = ['Convert to Uppercase','Convert to Lowercase','Convert First Letter to Uppercase',
+ 'Remove White Character from Beginning and End','Replace character or string (All)',
+ 'Replace character or string (the First one)','Replace character or string (the Last one)',
+ 'If it is empty fill with a fixed value','Add a fixed value at the start',
+ 'Add a fixed value at the end','Concatenate another field at the beginning',
+ 'Concatenate another field at the end'];
+ if(frm.doc.reference_doctype) {
+ frappe.model.with_doctype(frm.doc.reference_doctype, function() {
+ var options = $.map(frappe.get_meta(frm.doc.reference_doctype).fields,
+ function(d) {
+ if(d.fieldname && frappe.model.no_value_type.indexOf(d.fieldtype)===-1) {
+ return d.fieldname;
+ }
+ return null;
+ }
+ );
+ frm.set_df_property('origin_field', 'options', options);
+ frm.set_df_property('field_for_action', 'options', options);
+ });
+ }
+ if(frm.doc.origin_field) {
+ frappe.model.with_doctype(frm.doc.reference_doctype, function() {
+ var options = $.map(frappe.get_meta(frm.doc.reference_doctype).fields,
+ function(d) {
+ if(d.fieldname && d.fieldname==frm.doc.origin_field) {
+ return d.fieldtype;
+ }
+ return null;
+ }
+ );
+ frm.set_value('type', options[0]);
+ refresh_field('type');
+ });
+ var xact = [];
+ if(frm.doc.type != 'Int' && frm.doc.type != 'Float') {
+ xact = cact;
+ }
+ frm.set_df_property('action', 'options', xact);
+ frm.set_df_property('receiver_field', 'options', [frm.doc.origin_field, 'Create new field']);
+ frm.set_value('receiver_field', frm.doc.origin_field);
+ }
+ }
+});
diff --git a/pibiapp/external_data/doctype/conversion_rules/conversion_rules.json b/pibiapp/external_data/doctype/conversion_rules/conversion_rules.json
new file mode 100644
index 0000000..726c40e
--- /dev/null
+++ b/pibiapp/external_data/doctype/conversion_rules/conversion_rules.json
@@ -0,0 +1,507 @@
+{
+ "allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "autoname": "format:{reference_doctype}-{conversion_type}-{#####}",
+ "beta": 0,
+ "creation": "2019-03-24 16:36:17.182978",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "reference_doctype",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 1,
+ "label": "DocType External Data Source",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Ext Data Source",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 1,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "default": "During loading",
+ "fieldname": "conversion_type",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 1,
+ "label": "Conversion Type",
+ "length": 0,
+ "no_copy": 0,
+ "options": "During loading\nAfter loading",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 1,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_4",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "execution_order",
+ "fieldtype": "Int",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Execution Order",
+ "length": 10,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 1,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0,
+ "width": "0"
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "origin_field",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 1,
+ "label": "Origin Field",
+ "length": 0,
+ "no_copy": 0,
+ "options": "",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:doc.reference_doctype&&doc.origin_field&&doc.type",
+ "fieldname": "section_break_6",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "",
+ "fieldname": "type",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Type",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "action",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Action",
+ "length": 0,
+ "no_copy": 0,
+ "options": "",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "column_break_9",
+ "fieldtype": "Column Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "receiver_field",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Receiver Field",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:doc.action && doc.action.substr(0,3)==\"Rep\"",
+ "fieldname": "searched",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": " Searched",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:doc.action && (doc.action.substr(0,3)==\"Rep\" || doc.action.substr(0,2)==\"If\" || doc.action.substr(0,3)==\"Add\")",
+ "fieldname": "replace_by",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Value to be Included",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "depends_on": "eval:doc.action && doc.action.substr(0,5)==\"Conca\"",
+ "fieldname": "field_for_action",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Field for Action",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2019-03-27 17:14:28.715666",
+ "modified_by": "Administrator",
+ "module": "External Data",
+ "name": "Conversion Rules",
+ "name_case": "Title Case",
+ "owner": "Administrator",
+ "permissions": [
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "System Manager",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Administrator",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ }
+ ],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0,
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/pibiapp/external_data/doctype/conversion_rules/conversion_rules.py b/pibiapp/external_data/doctype/conversion_rules/conversion_rules.py
new file mode 100644
index 0000000..ff44fca
--- /dev/null
+++ b/pibiapp/external_data/doctype/conversion_rules/conversion_rules.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Dolores Juliana and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class ConversionRules(Document):
+ pass
diff --git a/pibiapp/external_data/doctype/conversion_rules/test_conversion_rules.py b/pibiapp/external_data/doctype/conversion_rules/test_conversion_rules.py
new file mode 100644
index 0000000..8a66853
--- /dev/null
+++ b/pibiapp/external_data/doctype/conversion_rules/test_conversion_rules.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Dolores Juliana and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestConversionRules(unittest.TestCase):
+ pass
diff --git a/pibiapp/external_data/doctype/ext_data_source/ext_data_source.js b/pibiapp/external_data/doctype/ext_data_source/ext_data_source.js
index ef4204c..6e69617 100644
--- a/pibiapp/external_data/doctype/ext_data_source/ext_data_source.js
+++ b/pibiapp/external_data/doctype/ext_data_source/ext_data_source.js
@@ -3,6 +3,19 @@
frappe.ui.form.on('Ext Data Source', {
refresh: function(frm) {
-
+ frm.page.add_menu_item(__("Clean Data Loaded"), function() {
+ if(frappe.confirm(__("This is PERMANENT action and you cannot undo. Continue?"),
+ function() {
+ return frappe.call({
+ method: 'pibiapp.external_data.data_manage.deletedata',
+ args: {
+ doctype: frm.doc.name
+ },
+ callback: function() {
+ frm.refresh();
+ }
+ });
+ }));
+ });
}
});
diff --git a/pibiapp/hooks.py b/pibiapp/hooks.py
index 74c62be..f5eabd7 100755
--- a/pibiapp/hooks.py
+++ b/pibiapp/hooks.py
@@ -98,6 +98,9 @@
"Ext Data Source": {
"on_submit": "pibiapp.external_data.data_manage.loaddata"
},
+ "Change DocType Empty": {
+ "on_submit": "pibiapp.external_data.data_manage.changedoctype"
+ },
"Successive loads": {
"on_submit": "pibiapp.external_data.data_manage.reloaddata"
}
@@ -124,6 +127,16 @@
# ]
# }
+scheduler_events = {
+ "daily_long": [
+ "pibiapp.nextcloud.doctype.nextcloud_settings.nextcloud_settings.take_backups_daily"
+ ],
+ "weekly_long": [
+ "pibiapp.nextcloud.doctype.nextcloud_settings.nextcloud_settings.take_backups_weekly"
+ ]
+}
+
+
# Testing
# -------
diff --git a/pibiapp/modules.txt b/pibiapp/modules.txt
index e1fff47..ebdf35e 100755
--- a/pibiapp/modules.txt
+++ b/pibiapp/modules.txt
@@ -1,2 +1,3 @@
Nextcloud
External Data
+Redash
\ No newline at end of file
diff --git a/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.js b/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.js
index cd9d040..e625201 100755
--- a/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.js
+++ b/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.js
@@ -1,9 +1,10 @@
-// Copyright (c) 2018, Pibico
+// Copyright (c) 2018-2019, Pibico
// For license information, please see license.txt
frappe.ui.form.on('Nextcloud Settings', {
refresh: function(frm) {
frm.clear_custom_buttons();
+ frm.events.take_backup(frm);
},
allow_nextcloud_access: function(frm) {
@@ -21,5 +22,15 @@ frappe.ui.form.on('Nextcloud Settings', {
else {
frappe.msgprint(__("Please enter values for Nextcloud Access Key and Nextcloud Access Secret"))
}
+ },
+ take_backup: function(frm) {
+ if (frm.doc.enable && frm.doc.enabled_nexcloud_upload && frm.doc.backup_frequency){
+ frm.add_custom_button(__("Take Backup Now"), function(frm){
+ frappe.call({
+ method: "pibiapp.nextcloud.doctype.nextcloud_settings.nextcloud_settings.take_backup",
+ freeze: true
+ })
+ }).addClass("btn-primary")
+ }
}
});
diff --git a/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.json b/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.json
index de82bf7..76bd33f 100755
--- a/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.json
+++ b/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.json
@@ -577,6 +577,204 @@
"set_only_once": 0,
"translatable": 0,
"unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 1,
+ "columns": 0,
+ "depends_on": "eval:doc.enable",
+ "fieldname": "backups_section",
+ "fieldtype": "Section Break",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Backups",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "default": "0",
+ "fieldname": "enabled_nexcloud_upload",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Enabled Nexcloud Upload",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "default": "0",
+ "fieldname": "file_backup",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "File Backup",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "send_notifications_to",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Send Notifications To",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "default": "1",
+ "fieldname": "send_email_for_successful_backup",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Send Email for Successful Backup",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "default": "Daily",
+ "fieldname": "backup_frequency",
+ "fieldtype": "Select",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Backup Frequency",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Daily\nWeekly",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
}
],
"has_web_view": 0,
@@ -589,7 +787,7 @@
"issingle": 1,
"istable": 0,
"max_attachments": 0,
- "modified": "2019-03-18 16:30:53.417135",
+ "modified": "2019-04-01 11:52:51.019306",
"modified_by": "Administrator",
"module": "Nextcloud",
"name": "Nextcloud Settings",
diff --git a/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.py b/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.py
index b1d14a2..285ff3d 100755
--- a/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.py
+++ b/pibiapp/nextcloud/doctype/nextcloud_settings/nextcloud_settings.py
@@ -1,12 +1,139 @@
-# Copyright (c) 2018, Pibico
-# -*- coding: utf-8 -*-
-# For license information, please see license_Pibico.txt
+# Copyright (c) 2019, Dolores Juliana Fdez Martin
+# License: GNU General Public License v3. See license.txt
+#
+# This file is part of Pibiapp_Nextcloud.
+#
+# Pibiapp_Nextcloud is free software: you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation, version 3 of the License.
+#
+# Pibiapp_Nextcloud is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Pibiapp_Nextcloud included in the license.txt file.
+# If not, see .
from __future__ import unicode_literals
import frappe
+import os
from frappe.model.document import Document
from frappe import _
-from pibiapp.nextcloud.nextcloud_link import nextcloud_callback
+from frappe.utils.backups import new_backup
+from frappe.utils.background_jobs import enqueue
+from pibiapp.nextcloud.nextcloud_link import nextcloud_callback, nextcloud_backup
+from rq.timeouts import JobTimeoutException
+from frappe.utils import (cint, split_emails, get_request_site_address,
+ get_files_path, get_backups_path, get_url, encode)
+from six import text_type, PY2
+
class NextcloudSettings(Document):
- pass
+ def validate(self):
+ if self.enable:
+ if (not self.client_id or self.client_id == ""
+ or not self.client_secret or self.client_secret == ""
+ or not self.script_url or self.script_url == ""
+ or not self.webdav_path or self.webdav_path == ""):
+ frappe.throw(_('If Nexcloud is enabled, the data is mandatory: Client id, Client Secret, Script Url and Webdav Path'))
+ if self.enabled_nexcloud_upload:
+ if (not self.send_notifications_to or self.send_notifications_to == ""
+ or not self.backup_frequency or self.backup_frequency == ""):
+ frappe.throw(_('If Nexcloud Backups is enabled, the data is mandatory: Send Notifications To, Backup Frequency'))
+
+@frappe.whitelist()
+def take_backup():
+ enqueue("pibiapp.nextcloud.doctype.nextcloud_settings.nextcloud_settings.take_backup_to_nextcloud", queue='long', timeout=1500)
+ frappe.msgprint(_("Queued for backup. It may take a few minutes to an hour."))
+
+def take_backups_daily():
+ take_backups_if("Daily")
+
+def take_backups_weekly():
+ take_backups_if("Weekly")
+
+def take_backups_if(freq):
+ if frappe.db.get_value("Nextcloud Settings", None, "backup_frequency") == freq:
+ take_backup_to_nextcloud()
+
+def take_backup_to_nextcloud(retry_count=0, upload_db_backup=True):
+ did_not_upload, error_log = [], []
+ nc = frappe.db.get_value("Nextcloud Settings", None, "enable")
+ ncb = frappe.db.get_value("Nextcloud Settings", None, "enabled_nexcloud_upload")
+ try:
+ if nc == "1" and ncb == "1":
+ ncbf = frappe.db.get_value("Nextcloud Settings", None, "file_backup")
+ ignore_files = False if ncbf else True
+ did_not_upload, error_log = backup_to_nextcloud(upload_db_backup, ignore_files)
+ if did_not_upload: raise Exception
+ send_email(True, "Nextcloud")
+ except JobTimeoutException:
+ if retry_count < 2:
+ args = {
+ "retry_count": retry_count + 1,
+ "upload_db_backup": False #considering till worker timeout db backup is uploaded
+ }
+ enqueue("pibiapp.nextcloud.doctype.nextcloud_settings.nextcloud_settings.take_backup_to_nextcloud",
+ queue='long', timeout=1500, **args)
+ except Exception:
+ file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)]
+ error_message = ("\n".join(file_and_error) + "\n" + frappe.get_traceback())
+ frappe.errprint(error_message)
+ send_email(False, "Nextcloud", error_message)
+
+def send_email(success, service_name, error_status=None):
+ if success:
+ if frappe.db.get_value("Nextcloud Settings", None, "send_email_for_successful_backup") == '0':
+ return
+
+ subject = "Backup Upload Successful"
+ message ="""Backup Uploaded Successfully
Hi there, this is just to inform you
+ that your backup was successfully uploaded to your %s account. So relax!
+ """ % service_name
+
+ else:
+ subject = "[Warning] Backup Upload Failed"
+ message ="""Backup Upload Failed
Oops, your automated backup to %s
+ failed.
+ Error message:
+
%s
+
+ Please contact your system manager for more information.
+ """ % (service_name, error_status)
+
+ if not frappe.db:
+ frappe.connect()
+
+ recipients = split_emails(frappe.db.get_value("Nextcloud Settings", None, "send_notifications_to"))
+ frappe.sendmail(recipients=recipients, subject=subject, message=message)
+
+def backup_to_nextcloud(upload_db_backup=True, ignore_files=True):
+ if not frappe.db:
+ frappe.connect()
+ respnc = ""
+ if upload_db_backup:
+ backup = new_backup(ignore_files=ignore_files)
+ filebackup = os.path.join(get_backups_path(), os.path.basename(backup.backup_path_db))
+ respnc = filebackup_upload(filebackup)
+ # file backup
+ if not ignore_files and not "Error" in respnc:
+ filebackup = os.path.join(get_backups_path(), os.path.basename(backup.backup_path_files))
+ respncf = filebackup_upload(filebackup)
+ filebackup = os.path.join(get_backups_path(), os.path.basename(backup.backup_path_private_files))
+ respncf = filebackup_upload(filebackup)
+ did_not_upload = []
+ if "Error" in respnc: error_log = [respnc]
+ else: error_log = []
+ return did_not_upload, list(set(error_log))
+
+def filebackup_upload(filebackup):
+ fname = filebackup.split("/backups/")[1]
+ doc = frappe.get_doc({"doctype":"File",
+ "attached_to_doctype": "Nextcloud Settings",
+ "attached_to_name": "Nextcloud Settings",
+ "is_folder": 0, "is_private": 1,
+ "name": fname, "file_name": fname,
+ "file_url": filebackup})
+ return nextcloud_backup(doc=doc)
diff --git a/pibiapp/nextcloud/nextcloud_link.py b/pibiapp/nextcloud/nextcloud_link.py
index b5cad67..94e9f9b 100755
--- a/pibiapp/nextcloud/nextcloud_link.py
+++ b/pibiapp/nextcloud/nextcloud_link.py
@@ -39,17 +39,18 @@ def __init__(self, doc=None):
docns = frappe.get_doc("Nextcloud Settings")
if not docns or not docns.enable:
return
- self.doctype = doc.attached_to_doctype
+ self.doctype = doc.attached_to_doctype if doc != None else "Nextcloud Settings"
self.module = get_doctype_module(self.doctype)
nem = frappe.get_all("Nextcloud Excluded Module", filters={ "parent": "Nextcloud Settings", "excluded_module": self.module }, fields=["excluded_module","doctypes","file_formats"], distinct=True)
if nem:
for row in nem:
- xdoctypes = row.doctypes
- xfile_formats = row.file_formats
- if xdoctypes == "" or "All" in xdoctypes or self.doctype in xdoctypes.split(","):
+ xdoctypes = row.doctypes.upper()
+ xfile_formats = row.file_formats.upper()
+ if xdoctypes == "" or "ALL" in xdoctypes or self.doctype.upper() in xdoctypes.split(","):
+ if doc == None or doc.file_name == None: return
a = doc.file_name.split(".")
xformat = a[len(a) - 1]
- if xfile_formats == "" or "All" in xfile_formats or xformat in xfile_formats.split(","):
+ if xfile_formats == "" or "ALL" in xfile_formats or xformat.upper() in xfile_formats.split(","):
return
self.app = get_module_app(self.module)
self.initialpath = docns.initial_path
@@ -324,3 +325,22 @@ def tagging_gb(doc, fileid):
nc = nextcloud_link(doc=doc)
doc.nc = nc
doc.nc.tagging(doc, fileid, relational=doc.nc.relationaltagging)
+@frappe.whitelist()
+def nextcloud_backup(doc, method=None):
+ doc.flags.ignore_nc = True
+ nc = nextcloud_link(doc=doc)
+ if not nc.isconnect: return "Error conection Nextcloud"
+ if not doc.file_name or doc.file_name == None: return "Error name backup file"
+ doc.flags.ignore_nc = False
+ local_fileobj = doc.file_url
+ fileobj = local_fileobj.split('/')
+ uu = len(fileobj) - 1
+ doc.nc = nc
+ doc.nc.module = "Backups"
+ doc.nc.path = nc.initialpath + "/" + nc.app + "/" + doc.nc.module
+ doc.nc.pathglobal = doc.nc.path + "/" + fileobj[uu].encode("ascii", "ignore").decode("ascii")
+ doc.nc.local_fileobj = local_fileobj
+ doc.nc.remote_fileobj=fileobj[uu].encode("ascii", "ignore").decode("ascii")
+ doc.nc.webdav.upload(local_fileobj=doc.nc.local_fileobj, remote_fileobj=doc.nc.remote_fileobj, nc_path=doc.nc.path)
+ data_json = doc.nc.shareModule(doc)
+ return "Upload backup"
diff --git a/pibiapp/redash/__init__.py b/pibiapp/redash/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pibiapp/redash/doctype/__init__.py b/pibiapp/redash/doctype/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pibiapp/redash/doctype/redash_business_intelligence/__init__.py b/pibiapp/redash/doctype/redash_business_intelligence/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.js b/pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.js
new file mode 100644
index 0000000..a12dd63
--- /dev/null
+++ b/pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.js
@@ -0,0 +1,28 @@
+// Copyright (c) 2019, Dolores Juliana and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Redash Business Intelligence', {
+ refresh: function(frm) {
+ var menuglobal;
+ frm.disable_save();
+ frm.page.clear_menu();
+ frappe.call({
+ method: "pibiapp.redash.doctype.redash_business_intelligence.redash_business_intelligence.get_dashboard",
+ callback: function(r) {
+ menuglobal = r.message;
+ document.getElementById('embedredash').src = menuglobal[0][1];
+ var x = menuglobal.length;
+ var i;
+ for (i = 0; i < x; i++) {
+ var myUrl = new URL(menuglobal[i][1]);
+ frm.page.add_menu_item(__(String(i + 1) + "- " + menuglobal[i][0]), function() {
+ var str = this.text;
+ var j = Number(str.substr(0, str.indexOf("-")));
+ j = j - 1;
+ document.getElementById('embedredash').src = menuglobal[j][1];
+ });
+ }
+ }
+ });
+ }
+});
diff --git a/pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.json b/pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.json
new file mode 100644
index 0000000..9a634df
--- /dev/null
+++ b/pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.json
@@ -0,0 +1,134 @@
+{
+ "allow_copy": 1,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2019-03-29 14:23:04.873427",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "redash_view",
+ "fieldtype": "HTML",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 1,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Redash view",
+ "length": 0,
+ "no_copy": 0,
+ "options": "",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 1,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 1,
+ "hide_toolbar": 1,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 1,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2019-03-31 17:05:48.372280",
+ "modified_by": "Administrator",
+ "module": "Redash",
+ "name": "Redash Business Intelligence",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 0,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 0,
+ "role": "System Manager",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 0,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 0,
+ "role": "Administrator",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 0,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 0,
+ "role": "All",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ }
+ ],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 0,
+ "track_seen": 0,
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.py b/pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.py
new file mode 100644
index 0000000..ac8de1a
--- /dev/null
+++ b/pibiapp/redash/doctype/redash_business_intelligence/redash_business_intelligence.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Dolores Juliana and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+from frappe import _
+
+class RedashBusinessIntelligence(Document):
+ pass
+
+@frappe.whitelist()
+def get_dashboard():
+ from frappe.utils import has_common
+ user_roles = frappe.get_roles()
+ list_dashboard = frappe.get_list("Redash Dashboards", fields=["name","title","url_dashboard"],
+ order_by="dborder", ignore_permissions=True)
+ out = []
+ for dashboard in list_dashboard:
+ dashboard_roles = [d.role for d in frappe.get_all("RedashPerm",
+ filters={"parent": dashboard.name}, fields=["role"], ignore_permissions=True)]
+ if has_common(user_roles, dashboard_roles):
+ out.append([dashboard.title, dashboard.url_dashboard])
+ return out
diff --git a/pibiapp/redash/doctype/redash_business_intelligence/test_redash_business_intelligence.py b/pibiapp/redash/doctype/redash_business_intelligence/test_redash_business_intelligence.py
new file mode 100644
index 0000000..79ebc3e
--- /dev/null
+++ b/pibiapp/redash/doctype/redash_business_intelligence/test_redash_business_intelligence.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Dolores Juliana and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestRedashBusinessIntelligence(unittest.TestCase):
+ pass
diff --git a/pibiapp/redash/doctype/redash_dashboards/__init__.py b/pibiapp/redash/doctype/redash_dashboards/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pibiapp/redash/doctype/redash_dashboards/redash_dashboards.js b/pibiapp/redash/doctype/redash_dashboards/redash_dashboards.js
new file mode 100644
index 0000000..31ed37d
--- /dev/null
+++ b/pibiapp/redash/doctype/redash_dashboards/redash_dashboards.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2019, Dolores Juliana and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Redash Dashboards', {
+ refresh: function(frm) {
+
+ }
+});
diff --git a/pibiapp/redash/doctype/redash_dashboards/redash_dashboards.json b/pibiapp/redash/doctype/redash_dashboards/redash_dashboards.json
new file mode 100644
index 0000000..a59d20a
--- /dev/null
+++ b/pibiapp/redash/doctype/redash_dashboards/redash_dashboards.json
@@ -0,0 +1,211 @@
+{
+ "allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2019-03-29 21:46:54.602299",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "title",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 1,
+ "in_list_view": 1,
+ "in_standard_filter": 1,
+ "label": "Title",
+ "length": 40,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "url_dashboard",
+ "fieldtype": "Small Text",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "URL Dashboard",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "dborder",
+ "fieldtype": "Int",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Order",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 1,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "roles",
+ "fieldtype": "Table",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Roles",
+ "length": 0,
+ "no_copy": 0,
+ "options": "RedashPerm",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 1,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 0,
+ "max_attachments": 0,
+ "modified": "2019-03-31 19:20:54.888713",
+ "modified_by": "Administrator",
+ "module": "Redash",
+ "name": "Redash Dashboards",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "System Manager",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ },
+ {
+ "amend": 0,
+ "cancel": 0,
+ "create": 1,
+ "delete": 1,
+ "email": 1,
+ "export": 1,
+ "if_owner": 0,
+ "import": 0,
+ "permlevel": 0,
+ "print": 1,
+ "read": 1,
+ "report": 1,
+ "role": "Administrator",
+ "set_user_permissions": 0,
+ "share": 1,
+ "submit": 0,
+ "write": 1
+ }
+ ],
+ "quick_entry": 0,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0,
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/pibiapp/redash/doctype/redash_dashboards/redash_dashboards.py b/pibiapp/redash/doctype/redash_dashboards/redash_dashboards.py
new file mode 100644
index 0000000..2a7d77b
--- /dev/null
+++ b/pibiapp/redash/doctype/redash_dashboards/redash_dashboards.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Dolores Juliana and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class RedashDashboards(Document):
+ pass
diff --git a/pibiapp/redash/doctype/redash_dashboards/test_redash_dashboards.py b/pibiapp/redash/doctype/redash_dashboards/test_redash_dashboards.py
new file mode 100644
index 0000000..c9c1f2b
--- /dev/null
+++ b/pibiapp/redash/doctype/redash_dashboards/test_redash_dashboards.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Dolores Juliana and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestRedashDashboards(unittest.TestCase):
+ pass
diff --git a/pibiapp/redash/doctype/redashperm/__init__.py b/pibiapp/redash/doctype/redashperm/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/pibiapp/redash/doctype/redashperm/redashperm.json b/pibiapp/redash/doctype/redashperm/redashperm.json
new file mode 100644
index 0000000..46ce761
--- /dev/null
+++ b/pibiapp/redash/doctype/redashperm/redashperm.json
@@ -0,0 +1,76 @@
+{
+ "allow_copy": 0,
+ "allow_events_in_timeline": 0,
+ "allow_guest_to_view": 0,
+ "allow_import": 0,
+ "allow_rename": 0,
+ "beta": 0,
+ "creation": "2019-03-30 09:50:24.118810",
+ "custom": 0,
+ "docstatus": 0,
+ "doctype": "DocType",
+ "document_type": "",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "fields": [
+ {
+ "allow_bulk_edit": 0,
+ "allow_in_quick_entry": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "role",
+ "fieldtype": "Link",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 1,
+ "in_standard_filter": 0,
+ "label": "Role",
+ "length": 0,
+ "no_copy": 0,
+ "options": "Role",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 1,
+ "search_index": 0,
+ "set_only_once": 0,
+ "translatable": 0,
+ "unique": 0
+ }
+ ],
+ "has_web_view": 0,
+ "hide_heading": 0,
+ "hide_toolbar": 0,
+ "idx": 0,
+ "image_view": 0,
+ "in_create": 0,
+ "is_submittable": 0,
+ "issingle": 0,
+ "istable": 1,
+ "max_attachments": 0,
+ "modified": "2019-03-31 18:39:53.063027",
+ "modified_by": "Administrator",
+ "module": "Redash",
+ "name": "RedashPerm",
+ "name_case": "",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "read_only": 0,
+ "read_only_onload": 0,
+ "show_name_in_global_search": 0,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1,
+ "track_seen": 0,
+ "track_views": 0
+}
\ No newline at end of file
diff --git a/pibiapp/redash/doctype/redashperm/redashperm.py b/pibiapp/redash/doctype/redashperm/redashperm.py
new file mode 100644
index 0000000..987789f
--- /dev/null
+++ b/pibiapp/redash/doctype/redashperm/redashperm.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Dolores Juliana and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.model.document import Document
+
+class RedashPerm(Document):
+ pass