From c5a0e909b0758edc12519e3ad5a4a663e659753f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 27 Jul 2011 18:13:56 +0530 Subject: [PATCH] fix to modules & js+css in doctype --- cgi-bin/webnotes/model/doctype.py | 7 ++++++- cgi-bin/webnotes/modules/__init__.py | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cgi-bin/webnotes/model/doctype.py b/cgi-bin/webnotes/model/doctype.py index 43e3dc983f..3aa11f6803 100644 --- a/cgi-bin/webnotes/model/doctype.py +++ b/cgi-bin/webnotes/model/doctype.py @@ -263,8 +263,13 @@ class _DocType: doclist = self._load_from_cache() from webnotes.modules import Module + + # add custom script if present + from webnotes.model.code import get_custom_script + custom = get_custom_script(dt, 'Client') or '' + doc = doclist[0] - doc.fields['__js'] = Module(doc.module).get_doc_file('doctype', doc.name, '.js').read() + doc.fields['__js'] = Module(doc.module).get_doc_file('doctype', doc.name, '.js').read() + custom doc.fields['__css'] = Module(doc.module).get_doc_file('doctype', doc.name, '.css').read() self._load_select_options(doclist) self._clear_code(doclist) diff --git a/cgi-bin/webnotes/modules/__init__.py b/cgi-bin/webnotes/modules/__init__.py index 9902a403bd..5c68714883 100644 --- a/cgi-bin/webnotes/modules/__init__.py +++ b/cgi-bin/webnotes/modules/__init__.py @@ -305,6 +305,7 @@ class JsModuleFile(ModuleFile): """ name = match.group('name') + custom = '' import webnotes.defs, os if os.path.sep in name: @@ -313,8 +314,12 @@ class JsModuleFile(ModuleFile): else: # its a doctype path = os.path.join(get_doc_path('DocType', name), scrub(name) + '.js') + + # add custom script if present + from webnotes.model.code import get_custom_script + custom = get_custom_script(dt, 'Client') or '' - return JsModuleFile(path).read() + return JsModuleFile(path).read() + custom def read(self): """