Refactored plugin architecture to allow custom script reports
diff --git a/patches/october_2013/p10_plugins_refactor.py b/patches/october_2013/p10_plugins_refactor.py
new file mode 100644
index 0000000..b37bef4
--- /dev/null
+++ b/patches/october_2013/p10_plugins_refactor.py
@@ -0,0 +1,24 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import webnotes, os, shutil
+
+def execute():
+ # changed cache key for plugin code files
+ for doctype in webnotes.conn.sql_list("""select name from `tabDocType`"""):
+ webnotes.cache().delete_value("_server_script:"+doctype)
+
+ # move custom script reports to plugins folder
+ for name in webnotes.conn.sql_list("""select name from `tabReport`
+ where report_type="Script Report" and is_standard="No" """):
+ bean = webnotes.bean("Report", name)
+ bean.save()
+
+ module = webnotes.conn.get_value("DocType", bean.doc.ref_doctype, "module")
+ path = webnotes.modules.get_doc_path(module, "Report", name)
+ for extn in ["py", "js"]:
+ file_path = os.path.join(path, name + "." + extn)
+ plugins_file_path = webnotes.plugins.get_path(module, "Report", name, extn=extn)
+ if not os.path.exists(plugins_file_path) and os.path.exists(file_path):
+ shutil.copyfile(file_path, plugins_file_path)
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 1581841..f882739 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -237,4 +237,5 @@
"patches.october_2013.p07_rename_for_territory",
"patches.june_2013.p07_taxes_price_list_for_territory",
"patches.october_2013.p08_cleanup_after_item_price_module_change",
+ "patches.october_2013.p10_plugins_refactor",
]
\ No newline at end of file
diff --git a/utilities/demo/make_erpnext_demo.py b/utilities/demo/make_erpnext_demo.py
index cda38d6..a094239 100644
--- a/utilities/demo/make_erpnext_demo.py
+++ b/utilities/demo/make_erpnext_demo.py
@@ -106,8 +106,8 @@
def make_demo_on_login_script():
import shutil
- from core.doctype.custom_script.custom_script import get_custom_server_script_path
- custom_script_path = get_custom_server_script_path("Control Panel")
+ import webnotes.plugins
+ custom_script_path = webnotes.plugins.get_path("Core", "DocType", "Control Panel")
webnotes.create_folder(os.path.dirname(custom_script_path))
shutil.copyfile(os.path.join(os.path.dirname(__file__), "demo_control_panel.py"), custom_script_path)