diff --git a/print_designer/pdf.py b/print_designer/pdf.py
index 74c5366..8260696 100644
--- a/print_designer/pdf.py
+++ b/print_designer/pdf.py
@@ -129,7 +129,8 @@ def get_raw_cmd_render_pd(doc: str, name: str | None = None, print_format: str |
document = frappe.get_doc(json.loads(doc))
document.check_permission()
print_format = get_print_format_doc(print_format, meta=document.meta)
- return { 'raw_commands' : get_rendered_template_pd(doc=document, print_format=print_format)}
+
+ return get_rendered_template_pd(doc=document, print_format=print_format)
def get_rendered_template_pd(
@@ -172,7 +173,7 @@ def get_rendered_template_pd(
raw_cmd_lang = settings.get('page').get('rawCmdLang')
if raw_cmd_lang is None:
- return f"
Please select the Raw Command language from Print Designer."
+ return {'status' : False, 'msg' : 'Language is not selected from Print Designer'}
for set_type in element_List:
for element in element_List[set_type]:
@@ -180,11 +181,15 @@ def get_rendered_template_pd(
rawCmdBeforeEle = element.get('childrens')[0].get('rawCmdBeforeEle', ' ').strip()
rawCmdAfterEle = element.get('childrens')[0].get('rawCmdAfterEle', ' ').strip()
- if rawCmdBeforeEle != "":
+ if rawCmdBeforeEle != "" and rawCmdBeforeEle != 'custom':
rawCmdBeforeEle = convert_str_raw_cmd(rawCmdBeforeEle, raw_cmd_lang)
-
- if rawCmdAfterEle != "":
+ elif rawCmdBeforeEle == 'custom':
+ rawCmdBeforeEle = element.get('childrens')[0].get('customRawCmdBeforeEle', ' ').strip()
+
+ if rawCmdAfterEle != "" and rawCmdAfterEle != 'custom':
rawCmdAfterEle = convert_str_raw_cmd(rawCmdAfterEle, raw_cmd_lang)
+ elif rawCmdAfterEle == 'custom':
+ rawCmdAfterEle = element.get('childrens')[0].get('customRawCmdAfterEle', ' ').strip()
args.update({"element": [element]})
#Need to change options value to raw_cmd
@@ -196,11 +201,11 @@ def get_rendered_template_pd(
except Exception as e :
error = log_error(title=e, reference_doctype="Print Format", reference_name=print_format.name)
if frappe.conf.developer_mode:
- return f"Something went wrong while rendering the print format.
If you don't know what just happened, and wish to file a ticket or issue on Github
Please copy the error from Error Log {error.name}
or ask Administrator.
Error rendering print format: {error.reference_name}
{error.method}
{html.escape(error.error)}
"
+ return { 'status' : False, 'msg' : f"Something went wrong while rendering the print format.
If you don't know what just happened, and wish to file a ticket or issue on Github
Please copy the error from Error Log {error.name}
or ask Administrator.
Error rendering print format: {error.reference_name}
{error.method}
{html.escape(error.error)}
"}
else:
- return f"Something went wrong while rendering the print format.
If you don't know what just happened, and wish to file a ticket or issue on Github
Please copy the error from Error Log {error.name}
or ask Administrator.
"
+ return { 'status' : False, 'msg' : f"Something went wrong while rendering the print format.
If you don't know what just happened, and wish to file a ticket or issue on Github
Please copy the error from Error Log {error.name}
or ask Administrator.
"}
- return html_with_raw_cmd_list
+ return {'status' : True, 'raw_commands' : html_with_raw_cmd_list}
def convert_str_raw_cmd(raw_string, printer_lang):
str_cmd_dict = {
diff --git a/print_designer/print_designer/client_scripts/print.js b/print_designer/print_designer/client_scripts/print.js
index 09b29cc..28221c1 100644
--- a/print_designer/print_designer/client_scripts/print.js
+++ b/print_designer/print_designer/client_scripts/print.js
@@ -280,6 +280,10 @@ frappe.ui.form.PrintView = class PrintView extends frappe.ui.form.PrintView {
frappe.ui.form
.qz_connect()
.then(function () {
+ if(!out.status){
+ frappe.throw(out.msg)
+ }
+
let printer_map = me.get_mapped_printer()[0];
let config = qz.configs.create(printer_map.printer);
return qz.print(config, out.raw_commands);
diff --git a/print_designer/public/js/print_designer/store/ElementStore.js b/print_designer/public/js/print_designer/store/ElementStore.js
index 4084aae..bd73c8b 100644
--- a/print_designer/public/js/print_designer/store/ElementStore.js
+++ b/print_designer/public/js/print_designer/store/ElementStore.js
@@ -468,6 +468,15 @@ export const useElementStore = defineStore("ElementStore", {
});
throw new Error(message);
}
+ if (MainStore.frappeControls['rawCmdLang'].value == null){
+ frappe.show_alert(
+ {
+ message: "Please select the language for raw cmd",
+ indicator: "red",
+ });
+ throw new Error('Please select the language for raw cmd');
+ }
+
const tableElement = this.Elements.filter((el) => el.type == "table");
if(this.isParentElementOverlapping(elements)){
throwOverlappingError("element", false);