diff --git a/.gitignore b/.gitignore index ca3fb77..b8ce83e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,6 @@ __pycache__ .idea/ .vscode/ node_modules/ -.backportrc.json \ No newline at end of file +.backportrc.json +label_printing/public/node_modules + diff --git a/label_printing/api.py b/label_printing/api.py index ea9595f..9752689 100644 --- a/label_printing/api.py +++ b/label_printing/api.py @@ -31,6 +31,8 @@ def print_label(values): doc.qty = label["item_qty"] if "information" in label: doc.information = label["information"] + if "is_warehouse_label" in label: + doc.is_warehouse_label = label["is_warehouse_label"] newdoc = doc.insert() diff --git a/label_printing/label_printing/doctype/label/label.json b/label_printing/label_printing/doctype/label/label.json index 6ef4e94..fed1575 100644 --- a/label_printing/label_printing/doctype/label/label.json +++ b/label_printing/label_printing/doctype/label/label.json @@ -14,7 +14,8 @@ "delivery_date", "customer", "batch", - "information" + "information", + "is_warehouse_label" ], "fields": [ { @@ -60,15 +61,22 @@ "fieldname": "information", "fieldtype": "Data", "label": "Information" + }, + { + "default": "0", + "fieldname": "is_warehouse_label", + "fieldtype": "Check", + "label": "Is Warehouse Label" } ], "icon": "fa fa-tag", "links": [], - "modified": "2022-02-17 09:25:53.912471", + "modified": "2023-05-11 08:17:16.609583", "modified_by": "Administrator", "module": "Label Printing", "name": "Label", "name_case": "UPPER CASE", + "naming_rule": "Expression (old style)", "owner": "Administrator", "permissions": [ { @@ -97,5 +105,6 @@ } ], "sort_field": "modified", - "sort_order": "DESC" + "sort_order": "DESC", + "states": [] } \ No newline at end of file diff --git a/label_printing/label_printing/print_format/label/label.json b/label_printing/label_printing/print_format/label/label.json index cf23602..a80240e 100644 --- a/label_printing/label_printing/print_format/label/label.json +++ b/label_printing/label_printing/print_format/label/label.json @@ -2,22 +2,23 @@ "absolute_value": 0, "align_labels_right": 0, "creation": "2022-03-01 09:42:22.551134", - "css": ".print-format {\n\tmargin: 0;\n\tpadding: 0;\n margin-left: 1mm;\n margin-right: 1mm;\n margin-top: 1mm;\n margin-bottom: 1mm;\n\twidth: 100mm;\n\tmax-height: 39mm;\n}\n\n.page-size {\n\twidth: 104mm;\n\theight: 40mm;\n}\n\n.label-wrapper {\n\twidth: 100mm;\n\ttext-align: center;\n\tdisplay: -webkit-box;\n\t/* wkhtmltopdf uses this one */\n\tdisplay: -webkit-flex;\n\tdisplay: flex;\n\t-webkit-box-pack: center;\n\t/* wkhtmltopdf uses this one */\n\t-webkit-justify-content: center;\n\tjustify-content: center;\n\tfont-size: 15px;\n}\n\n.left-wrapper {\n\twidth: 80mm;\n}\n\n.left-wrapper div {\n\twhite-space: nowrap;\n\tfont-size: 12px;\n}\n\n.right-wrapper {\n\twidth: 20mm;\n\ttext-align: right;\n}\n\n.label-wrapper h4 {\n\tmargin: 0;\n\twhite-space: nowrap;\n\tfont-size: 23px;\n}\n\n.label-wrapper h4 small {\n\tcolor: black;\n}\n\n", + "css": ".print-format {\n\tmargin: 0;\n\tpadding: 0;\n margin-left: 1mm;\n margin-right: 1mm;\n margin-top: 1mm;\n margin-bottom: 1mm;\n\twidth: 100mm;\n\tmax-height: 39mm;\n}\n\n.page-size {\n\twidth: 104mm;\n\theight: 40mm;\n}\n\n.label-wrapper {\n\twidth: 104mm;\n\ttext-align: center;\n\tdisplay: -webkit-box;\n\t/* wkhtmltopdf uses this one */\n\tdisplay: -webkit-flex;\n\tdisplay: flex;\n\t-webkit-box-pack: center;\n\t/* wkhtmltopdf uses this one */\n\t-webkit-justify-content: center;\n\tjustify-content: center;\n\tfont-size: 15px;\n}\n\n.left-wrapper {\n\twidth: 80mm;\n\tmargin-top: 1mm;\n}\n\n.left-wrapper div {\n\twhite-space: nowrap;\n\tfont-size: 12px;\n}\n\n.right-wrapper {\n\twidth: 20mm;\n\ttext-align: right;\n}\n\n.label-wrapper h4 {\n\tmargin: 0;\n\twhite-space: nowrap;\n\tfont-size: 23px;\n}\n\n.label-wrapper h5 {\n\tmargin: 0;\n\twhite-space: nowrap;\n\tfont-size: 15px;\n}\n\n\n.right-wrapper {\n padding-right: 2mm;\n padding-top: 0.5mm;\n}\n", "custom_format": 1, + "default_print_language": "de", "disabled": 0, "doc_type": "Label", "docstatus": 0, "doctype": "Print Format", "font": "Default", "font_size": 0, - "html": "{% if doc.customer %}\n
\n\n
\n {% if doc.item_code %}\n

\n {{doc.item_code}}\n

\n {% endif %}\n\n {% if doc.item_name%}\n

\n {{doc.item_name}}\n

\n {% endif %}\n\n\n {% if doc.customer %}\n
{{doc.customer}}
\n {% endif %}\n\n {% if doc.delivery_date %}\n
\n {{_(\"Delivery Date\")}} {{frappe.utils.formatdate(doc.delivery_date, \"dd.MM.YYYY\")}}\n
\n {% endif %}\n\n {% if doc.batch %}\n
\n {{_(\"Batch\")}} {{doc.batch}}\n
\n {% endif %}\n\n {% if doc.qty %}\n
\n {{_(\"Qty\")}} {{ doc.qty }}\n
\n {% endif %}\n\n {% if doc.information%}\n
\n {{doc.information}}\n
\n {% endif %}\n\n\n
\n \n
\n \n
\n
\n\n{% else %}\n\n
\n\n
\n {% if doc.item_code %}\n

\n {{doc.item_code}}\n

\n {% endif %}\n\n\n {% if doc.batch %}\n
\n {{_(\"Batch\")}} {{doc.batch}}\n
\n {% endif %}\n\n\n {% if doc.information%}\n
\n {{doc.information}}\n
\n {% endif %}\n\n\n
\n
\n\n{% endif %}", + "html": "{% if not doc.is_warehouse_label == true %} \n
\n
\n {% if doc.customer %} \n
{{doc.customer}}
\n {% endif %}\n {% if doc.item_code %} \n

{{doc.item_code}}

\n {% endif %}\n {% if doc.item_name%} \n
{{doc.item_name}}
\n {% endif %}\n {% if doc.delivery_date %} \n
{{_(\"Delivery Date\")}} {{frappe.utils.formatdate(doc.delivery_date, \"dd.MM.YYYY\")}}
\n {% endif %}\n {% if doc.qty %} \n
{{_(\"Qty\")}} {{ doc.qty }}
\n {% endif %}\n {% if doc.batch %}\n
{{_(\"Batch\")}} {{doc.batch}}
\n {% endif %}\n \n {% if doc.information%} \n
{{doc.information}}
\n {% endif %} \n
\n
\n
\n{% else %} \n
\n
\n {% if doc.customer %} \n
{{doc.customer}}
\n {% endif %}\n {% if doc.item_code %} \n

{{doc.item_code}}

\n {% endif %}\n {% if doc.item_name%} \n
{{doc.item_name}}
\n {% endif %}\n \n {% if doc.batch %}\n
{{_(\"Batch\")}} {{doc.batch}}
\n {% endif %}\n \n {% if doc.information%} \n
{{doc.information}}
\n {% endif %} \n
\n
\n{% endif %}\n", "idx": 0, "line_breaks": 0, "margin_bottom": 0.0, "margin_left": 0.0, "margin_right": 0.0, "margin_top": 0.0, - "modified": "2022-11-10 12:13:59.766486", + "modified": "2023-08-28 13:06:58.300849", "modified_by": "Administrator", "module": "Label Printing", "name": "Label", diff --git a/label_printing/public/js/label_printing_desk.js b/label_printing/public/js/label_printing_desk.js index c399e5e..2ffc13d 100644 --- a/label_printing/public/js/label_printing_desk.js +++ b/label_printing/public/js/label_printing_desk.js @@ -28,16 +28,17 @@ function setupLabelsDialog(page) { } } - let label_printer_names - let d = new frappe.ui.Dialog({ title: __("Print Labels"), fields: [{ label: __("Reference Doctype"), - options: ['Work Order', 'Item', 'Label'], + options: ['Work Order', 'Item', 'Label', 'Stock Entry'], fieldname: 'doctype', fieldtype: 'Select', - default: fields.doctype, + default: cur_frm.doc.doctype, + onchange() { + d.set_df_property('docname', 'options', d.fields_dict.doctype.value); + } }, { label: __("Get data"), @@ -53,9 +54,9 @@ function setupLabelsDialog(page) { { label: __("Reference Docname"), fieldname: 'docname', - fieldtype: 'Data', - options: 'doctype', - default: fields.docname, + fieldtype: 'Link', + options: cur_frm.doc.doctype, + default: cur_frm.doc.name }, { fieldtype: 'Section Break', @@ -98,12 +99,20 @@ function setupLabelsDialog(page) { options: ['Labeldrucker Werk 1 (Ind. 6)', 'Labeldrucker Werk 2 (Bre. 19)'], fieldname: 'printer_select', fieldtype: 'Select', - default: 'Labeldrucker Werk 1 (Ind. 6)' + default: 'Labeldrucker Werk 2 (Bre. 19)' }, { fieldtype: 'Section Break', label: __('Labels') }, + { + label: __("Add Warehouse Label"), + fieldname: 'add_warehouse_label', + fieldtype: 'Button', + click: () => { + addWarehouseLabel() + } + }, { fieldname: "labels", fieldtype: "Table", @@ -131,6 +140,12 @@ function setupLabelsDialog(page) { in_list_view: 1, label: __('Information') }, + { + label: __("Is Warehouse Labael"), + fieldname: 'is_warehouse_label', + in_list_view: 1, + fieldtype: 'Check' + }, ] }, ], @@ -210,11 +225,47 @@ function setupLabelsDialog(page) { fields.customer = doc.associated_company } } + } else if (fields.doctype === "Stock Entry") { + let item = get_doc("Item", doc.items.slice(-1)[0].item_code) + let workorder = get_doc("Work Order", doc.work_order) + + fields.item_code = item.item_code + fields.item_name = item.item_name + fields.delivery_date = workorder.expected_delivery_date + fields.labels[0].item_qty = workorder.qty + fields.labels[0].label_qty = 1 + fields.batch = doc.items.slice(-1)[0].batch_no + + if (item.associated_company) { + let customer = get_doc("Customer", item.associated_company) + if (customer.short_name) { + fields.customer = customer.short_name + } else { + fields.customer = item.associated_company + } + } + + fields.total_amount = doc.qty + d.fields_dict.labels.refresh(); + } d.set_values(fields) } } + function addWarehouseLabel() { + fields = d.get_values() + let newRow = { + item_qty: 0, + label_qty: 1, + is_warehouse_label: true, + } + let tempValues = d.get_values() + tempValues.labels.push({ item_qty: 0, label_qty: 0, is_warehouse_label: true }) + console.log(tempValues) + d.fields_dict.labels.refresh() + } + } function get_doc(doctype, docname) { diff --git a/label_printing/public/node_modules b/label_printing/public/node_modules index b34ef5a..20b0786 120000 --- a/label_printing/public/node_modules +++ b/label_printing/public/node_modules @@ -1 +1 @@ -/home/frappe/frappe-bench/apps/label_printing/node_modules \ No newline at end of file +/workspace/development/frappe-bench/apps/label_printing/node_modules \ No newline at end of file