diff --git a/core/doctype/print_format/print_format.py b/core/doctype/print_format/print_format.py index b0dbe218e7..9a1e68b5cf 100644 --- a/core/doctype/print_format/print_format.py +++ b/core/doctype/print_format/print_format.py @@ -21,13 +21,16 @@ # from __future__ import unicode_literals -import webnotes +import webnotes, conf class DocType: def __init__(self, d, dl): self.doc, self.doclist = d,dl def validate(self): + if self.doc.standard=="Yes" and webnotes.session.user != "Administrator": + webnotes.msgprint("Standard Print Format cannot be updated.", raise_exception=1) + # old_doc_type is required for clearing item cache self.old_doc_type = webnotes.conn.get_value('Print Format', self.doc.name, 'doc_type') @@ -37,6 +40,15 @@ class DocType: webnotes.clear_cache(doctype=self.old_doc_type) if self.doc.doc_type: webnotes.clear_cache(doctype=self.doc.doc_type) + + self.export_doc() + + def export_doc(self): + # export + if self.doc.standard == 'Yes' and getattr(conf, 'developer_mode', 0) == 1: + from webnotes.modules.export_file import export_to_files + export_to_files(record_list=[['Print Format', self.doc.name]], + record_module=self.doc.module) def on_trash(self): if self.doc.doc_type: diff --git a/webnotes/modules/patch_handler.py b/webnotes/modules/patch_handler.py index b2ce4160c4..704af35279 100644 --- a/webnotes/modules/patch_handler.py +++ b/webnotes/modules/patch_handler.py @@ -68,7 +68,10 @@ def execute_patch(patchmodule, method=None, methodargs=None): try: log('Executing %s in %s' % (patchmodule or str(methodargs), webnotes.conn.cur_db_name)) if patchmodule: - webnotes.get_method(patchmodule + ".execute")() + if patchmodule.startswith("execute:"): + exec patchmodule.split("execute:")[1] in globals() + else: + webnotes.get_method(patchmodule + ".execute")() update_patch_log(patchmodule) elif method: method(**methodargs)