Compare commits
11 Commits
version-13
...
version-15
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d1cfdb88a | |||
| 3664311505 | |||
| 3ea3ed2e02 | |||
| 33cefa96e1 | |||
| 155d7a9a7c | |||
| 6a6212e163 | |||
| 494c7d622f | |||
|
|
baceb8fb66 | ||
|
|
10ffbf0f44 | ||
|
|
86ec8cf99d | ||
|
|
415f0f5d84 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -7,7 +7,8 @@ latest_updates.json
|
|||||||
.wnf-lang-status
|
.wnf-lang-status
|
||||||
*.egg-info
|
*.egg-info
|
||||||
dist/
|
dist/
|
||||||
erpnext/docs/current
|
label_printing/public/dist
|
||||||
|
label_printing/docs/current
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
__pycache__
|
__pycache__
|
||||||
@@ -15,3 +16,6 @@ __pycache__
|
|||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
.backportrc.json
|
||||||
|
label_printing/public/node_modules
|
||||||
|
*/node_modules/*
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
|
|
||||||
__version__ = '0.0.1'
|
__version__ = '14.38.0'
|
||||||
|
|
||||||
|
|||||||
@@ -4,21 +4,15 @@ import frappe
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
from pypdf import PdfWriter
|
||||||
|
|
||||||
from frappe.utils.pdf import get_pdf, cleanup
|
|
||||||
from frappe.core.doctype.access_log.access_log import make_access_log
|
|
||||||
from PyPDF2 import PdfFileWriter
|
|
||||||
from frappe.utils.jinja import render_template
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def print_label(values):
|
def print_label(values):
|
||||||
values = json.loads(values)
|
values = json.loads(values)
|
||||||
printer_setting = frappe.db.get_single_value(
|
|
||||||
'Label Printer Settings', 'label_printer'),
|
print_format = frappe.get_value(
|
||||||
print_format = frappe.db.get_single_value(
|
"Label Printer", values["printer_select"], "label_print_format")
|
||||||
'Label Printer Settings', 'label_print_format')
|
|
||||||
|
|
||||||
for label in values["labels"]:
|
for label in values["labels"]:
|
||||||
doc = frappe.new_doc('Label')
|
doc = frappe.new_doc('Label')
|
||||||
@@ -36,23 +30,26 @@ def print_label(values):
|
|||||||
doc.qty = label["item_qty"]
|
doc.qty = label["item_qty"]
|
||||||
if "information" in label:
|
if "information" in label:
|
||||||
doc.information = label["information"]
|
doc.information = label["information"]
|
||||||
|
if "is_warehouse_label" in label:
|
||||||
|
doc.is_warehouse_label = label["is_warehouse_label"]
|
||||||
|
|
||||||
newdoc = doc.insert()
|
newdoc = doc.insert()
|
||||||
|
|
||||||
print_label_by_server(
|
print_label_by_server(
|
||||||
"Label", newdoc.name, label["label_qty"], printer_setting[0], print_format, doc=None, no_letterhead=0, file_path=None)
|
"Label", newdoc.name, label["label_qty"], values["printer_select"], print_format, doc=None, no_letterhead=0, file_path=None)
|
||||||
|
|
||||||
return 200
|
return 200
|
||||||
|
|
||||||
|
|
||||||
def print_label_by_server(doctype, name, qty, printer_setting, print_format=None, doc=None, no_letterhead=0, file_path=None):
|
def print_label_by_server(doctype, name, qty, printer_setting, print_format=None, doc=None, no_letterhead=0, file_path=None):
|
||||||
pdf_options = {
|
pdf_options = {
|
||||||
'page-width': '{0}mm'.format(frappe.db.get_single_value('Label Printer Settings', 'label_width')),
|
'page-width': '{0}mm'.format(frappe.get_value("Label Printer", printer_setting, "label_width")),
|
||||||
'page-height': '{0}mm'.format(frappe.db.get_single_value('Label Printer Settings', 'label_height')),
|
'page-height': '{0}mm'.format(frappe.get_value("Label Printer", printer_setting, "label_height")),
|
||||||
}
|
}
|
||||||
|
|
||||||
print_settings = frappe.get_doc(
|
print_settings = frappe.get_doc(
|
||||||
"Network Printer Settings", printer_setting)
|
"Network Printer Settings", printer_setting)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import cups
|
import cups
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -62,25 +59,27 @@ def print_label_by_server(doctype, name, qty, printer_setting, print_format=None
|
|||||||
cups.setServer(print_settings.server_ip)
|
cups.setServer(print_settings.server_ip)
|
||||||
cups.setPort(print_settings.port)
|
cups.setPort(print_settings.port)
|
||||||
conn = cups.Connection()
|
conn = cups.Connection()
|
||||||
output = PdfFileWriter()
|
output = PdfWriter()
|
||||||
output = frappe.get_print(doctype, name, print_format, doc=doc,
|
output = frappe.get_print(doctype, name, print_format, doc=doc,
|
||||||
no_letterhead=no_letterhead, as_pdf=True, output=output, pdf_options=pdf_options)
|
no_letterhead=no_letterhead, as_pdf=True, output=output, pdf_options=pdf_options)
|
||||||
if not file_path:
|
if not file_path:
|
||||||
file_path = os.path.join(
|
file_path = os.path.join(
|
||||||
"/", "tmp", "frappe-pdf-{0}.pdf".format(frappe.generate_hash()))
|
"/", "tmp", f"frappe-pdf-{frappe.generate_hash()}.pdf")
|
||||||
output.write(open(file_path, "wb"))
|
output.write(open(file_path, "wb"))
|
||||||
for _ in range(qty):
|
for _ in range(qty):
|
||||||
conn.printFile(print_settings.printer_name, file_path, name, {})
|
conn.printFile(print_settings.printer_name,
|
||||||
except IOError as e:
|
file_path, name, {})
|
||||||
if ("ContentNotFoundError" in e.message
|
|
||||||
|
except OSError as e:
|
||||||
|
if (
|
||||||
|
"ContentNotFoundError" in e.message
|
||||||
or "ContentOperationNotPermittedError" in e.message
|
or "ContentOperationNotPermittedError" in e.message
|
||||||
or "UnknownContentError" in e.message
|
or "UnknownContentError" in e.message
|
||||||
or "RemoteHostClosedError" in e.message):
|
or "RemoteHostClosedError" in e.message
|
||||||
|
):
|
||||||
frappe.throw(_("PDF generation failed"))
|
frappe.throw(_("PDF generation failed"))
|
||||||
except cups.IPPError:
|
except cups.IPPError:
|
||||||
frappe.throw(_("Printing failed"))
|
frappe.throw(_("Printing failed"))
|
||||||
finally:
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from . import __version__ as app_version
|
from frappe import _
|
||||||
|
|
||||||
app_name = "label_printing"
|
app_name = "label_printing"
|
||||||
app_title = "Label Printing"
|
app_title = "Label Printing"
|
||||||
@@ -8,13 +8,14 @@ app_icon = "octicon octicon-file-directory"
|
|||||||
app_color = "grey"
|
app_color = "grey"
|
||||||
app_email = "admin@canetzberger.design"
|
app_email = "admin@canetzberger.design"
|
||||||
app_license = "MIT"
|
app_license = "MIT"
|
||||||
|
required_apps = ["erpnext"]
|
||||||
|
|
||||||
# Includes in <head>
|
# Includes in <head>
|
||||||
# ------------------
|
# ------------------
|
||||||
|
|
||||||
# include js, css files in header of desk.html
|
# include js, css files in header of desk.html
|
||||||
# app_include_css = "/assets/label_printing/css/label_printing.css"
|
# app_include_css = "/assets/label_printing/css/label_printing.css"
|
||||||
app_include_js = "/assets/js/label_printing.min.js"
|
app_include_js = "label_printing.bundle.js"
|
||||||
|
|
||||||
# include js, css files in header of web template
|
# include js, css files in header of web template
|
||||||
# web_include_css = "/assets/label_printing/css/label_printing.css"
|
# web_include_css = "/assets/label_printing/css/label_printing.css"
|
||||||
@@ -148,30 +149,6 @@ app_include_js = "/assets/js/label_printing.min.js"
|
|||||||
# auto_cancel_exempted_doctypes = ["Auto Repeat"]
|
# auto_cancel_exempted_doctypes = ["Auto Repeat"]
|
||||||
|
|
||||||
|
|
||||||
# User Data Protection
|
|
||||||
# --------------------
|
|
||||||
|
|
||||||
user_data_fields = [
|
|
||||||
{
|
|
||||||
"doctype": "{doctype_1}",
|
|
||||||
"filter_by": "{filter_by}",
|
|
||||||
"redact_fields": ["{field_1}", "{field_2}"],
|
|
||||||
"partial": 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "{doctype_2}",
|
|
||||||
"filter_by": "{filter_by}",
|
|
||||||
"partial": 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "{doctype_3}",
|
|
||||||
"strict": False,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "{doctype_4}"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
# Authentication and authorization
|
# Authentication and authorization
|
||||||
# --------------------------------
|
# --------------------------------
|
||||||
|
|
||||||
@@ -179,9 +156,9 @@ user_data_fields = [
|
|||||||
# "label_printing.auth.validate"
|
# "label_printing.auth.validate"
|
||||||
# ]
|
# ]
|
||||||
|
|
||||||
jenv = {
|
jinja = {
|
||||||
"methods": [
|
"methods": [
|
||||||
"generateBarcode:label_printing.utils.barcode.generateBarcode",
|
"label_printing.utils.barcode.generateBarcode",
|
||||||
"get_code128_glyphs:label_printing.utils.barcode.generateBarcodeGlyphs"
|
"label_printing.utils.barcode.generateBarcodeGlyphs"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ import json
|
|||||||
def create_labels(values):
|
def create_labels(values):
|
||||||
|
|
||||||
values = json.loads(values)
|
values = json.loads(values)
|
||||||
print(values)
|
|
||||||
|
|
||||||
print(values["item_code"])
|
|
||||||
|
|
||||||
doc = frappe.new_doc('Label')
|
doc = frappe.new_doc('Label')
|
||||||
doc.item_code = values["item_code"]
|
doc.item_code = values["item_code"]
|
||||||
@@ -20,7 +17,6 @@ def create_labels(values):
|
|||||||
ignore_if_duplicate=True, # dont insert if DuplicateEntryError is thrown
|
ignore_if_duplicate=True, # dont insert if DuplicateEntryError is thrown
|
||||||
ignore_mandatory=True # insert even if mandatory fields are not set
|
ignore_mandatory=True # insert even if mandatory fields are not set
|
||||||
)
|
)
|
||||||
print(res)
|
|
||||||
|
|
||||||
# print_by_server("Label", "Label-00001", "labelprinter", "Labels")
|
# print_by_server("Label", "Label-00001", "labelprinter", "Labels")
|
||||||
return 200
|
return 200
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
"delivery_date",
|
"delivery_date",
|
||||||
"customer",
|
"customer",
|
||||||
"batch",
|
"batch",
|
||||||
"information"
|
"information",
|
||||||
|
"is_warehouse_label"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -60,15 +61,22 @@
|
|||||||
"fieldname": "information",
|
"fieldname": "information",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Information"
|
"label": "Information"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "is_warehouse_label",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Is Warehouse Label"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "fa fa-tag",
|
"icon": "fa fa-tag",
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-02-17 09:25:53.912471",
|
"modified": "2023-05-11 08:17:16.609583",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Label Printing",
|
"module": "Label Printing",
|
||||||
"name": "Label",
|
"name": "Label",
|
||||||
"name_case": "UPPER CASE",
|
"name_case": "UPPER CASE",
|
||||||
|
"naming_rule": "Expression (old style)",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
@@ -97,5 +105,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC"
|
"sort_order": "DESC",
|
||||||
|
"states": []
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
"actions": [],
|
||||||
"allow_rename": 1,
|
"autoname": "field:label_printer",
|
||||||
"creation": "2022-02-09 11:54:25.055075",
|
"creation": "2022-11-09 10:36:02.195555",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
@@ -15,48 +15,47 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "label_printer",
|
"fieldname": "label_printer",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Label Printer",
|
"label": "Label Printer",
|
||||||
"options": "Network Printer Settings"
|
"options": "Network Printer Settings",
|
||||||
|
"reqd": 1,
|
||||||
|
"unique": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "in mm",
|
|
||||||
"fieldname": "label_height",
|
"fieldname": "label_height",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Label Height"
|
"in_list_view": 1,
|
||||||
|
"label": "Label Height",
|
||||||
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "in mm",
|
|
||||||
"fieldname": "label_width",
|
"fieldname": "label_width",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Label Width"
|
"in_list_view": 1,
|
||||||
|
"label": "Label Width",
|
||||||
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "label_print_format",
|
"fieldname": "label_print_format",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Label Print Format",
|
"label": "Label Print Format",
|
||||||
"options": "Print Format"
|
"options": "Print Format",
|
||||||
|
"reqd": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2022-04-03 14:50:49.776678",
|
"modified": "2022-11-09 12:27:38.327808",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Label Printing",
|
"module": "Label Printing",
|
||||||
"name": "Label Printer Settings",
|
"name": "Label Printer",
|
||||||
|
"name_case": "Title Case",
|
||||||
|
"naming_rule": "By fieldname",
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [],
|
||||||
{
|
|
||||||
"create": 1,
|
|
||||||
"delete": 1,
|
|
||||||
"email": 1,
|
|
||||||
"print": 1,
|
|
||||||
"read": 1,
|
|
||||||
"role": "System Manager",
|
|
||||||
"share": 1,
|
|
||||||
"write": 1
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC"
|
"sort_order": "DESC",
|
||||||
|
"states": []
|
||||||
}
|
}
|
||||||
@@ -4,5 +4,5 @@
|
|||||||
# import frappe
|
# import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class LabelPrinterSettings(Document):
|
class LabelPrinter(Document):
|
||||||
pass
|
pass
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2022, CAnetzberger Design and contributors
|
// Copyright (c) 2022, CAnetzberger Design and contributors
|
||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('Label Printer Settings', {
|
frappe.ui.form.on('Label Printing Settings', {
|
||||||
// refresh: function(frm) {
|
// refresh: function(frm) {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"creation": "2022-02-09 11:54:25.055075",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"enable_label_printing",
|
||||||
|
"label_printers"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "enable_label_printing",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Enable Label Printing"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"depends_on": "enable_label_printing",
|
||||||
|
"fieldname": "label_printers",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Label Printers",
|
||||||
|
"options": "Label Printer"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"issingle": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2022-11-09 10:42:37.066676",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "Label Printing",
|
||||||
|
"name": "Label Printing Settings",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"states": []
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2022, CAnetzberger Design and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class LabelPrintingSettings(Document):
|
||||||
|
pass
|
||||||
@@ -4,5 +4,5 @@
|
|||||||
# import frappe
|
# import frappe
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
class TestLabelPrinterSettings(unittest.TestCase):
|
class TestLabelPrintingSettings(unittest.TestCase):
|
||||||
pass
|
pass
|
||||||
@@ -2,22 +2,29 @@
|
|||||||
"absolute_value": 0,
|
"absolute_value": 0,
|
||||||
"align_labels_right": 0,
|
"align_labels_right": 0,
|
||||||
"creation": "2022-03-01 09:42:22.551134",
|
"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\tword-break: break-all;\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,
|
"custom_format": 1,
|
||||||
|
"default_print_language": "de",
|
||||||
"disabled": 0,
|
"disabled": 0,
|
||||||
"doc_type": "Label",
|
"doc_type": "Label",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "Print Format",
|
"doctype": "Print Format",
|
||||||
"font": "Default",
|
"font": "Default",
|
||||||
"html": "{% if doc.customer %}\n<div class=\"label-wrapper\">\n\n <div class=\"left-wrapper\">\n {% if doc.item_code %}\n <h4>\n <strong>{{doc.item_code}}</strong>\n </h4>\n {% endif %}\n\n {% if doc.item_name%}\n <h4>\n <small> {{doc.item_name}}</small>\n </h4>\n {% endif %}\n\n\n {% if doc.customer %}\n <div>{{doc.customer}}</div>\n {% endif %}\n\n {% if doc.delivery_date %}\n <div>\n <strong> {{_(\"Delivery Date\")}} </strong> {{frappe.utils.formatdate(doc.delivery_date, \"dd.MM.YYYY\")}}\n </div>\n {% endif %}\n\n {% if doc.batch %}\n <div>\n <strong>{{_(\"Batch\")}} </strong> {{doc.batch}}\n </div>\n {% endif %}\n\n {% if doc.qty %}\n <div>\n <strong>{{_(\"Qty\")}} </strong> {{ doc.qty }}\n </div>\n {% endif %}\n\n {% if doc.information%}\n <div>\n {{doc.information}}\n </div>\n {% endif %}\n\n\n </div>\n \n <div class=\"right-wrapper\">\n <img src=\"/files/hp_logo_black.jpg\" style=\"width: 30px;\">\n </div>\n</div>\n\n{% else %}\n\n<div class=\"label-wrapper\">\n\n <div class=\"left-wrapper\">\n {% if doc.item_code %}\n <h4 style=\"font-size: 30px; white-space: normal; padding: 2mm;\">\n <strong>{{doc.item_code}}</strong>\n </h4>\n {% endif %}\n\n\n {% if doc.batch %}\n <div style=\"font-size: 15px;\">\n <strong>{{_(\"Batch\")}} </strong> {{doc.batch}}\n </div>\n {% endif %}\n\n\n {% if doc.information%}\n <div>\n {{doc.information}}\n </div>\n {% endif %}\n\n\n </div>\n</div>\n\n{% endif %}",
|
"font_size": 0,
|
||||||
|
"html": "{% if not doc.is_warehouse_label == true %} \n<div class=\"label-wrapper\">\n <div class=\"left-wrapper\">\n {% if doc.customer %} \n <h5><strong>{{doc.customer}}</strong></h5>\n {% endif %}\n {% if doc.item_code %} \n <h4><strong>{{doc.item_code}}</strong></h4>\n {% endif %}\n {% if doc.item_name%} \n <h5>{{doc.item_name}}</h5>\n {% endif %}\n {% if doc.delivery_date %} \n <div> <strong> {{_(\"Delivery Date\")}} </strong> {{frappe.utils.formatdate(doc.delivery_date, \"dd.MM.YYYY\")}} </div>\n {% endif %}\n {% if doc.qty %} \n <div> <strong>{{_(\"Qty\")}} </strong> {{ doc.qty }}</div>\n {% endif %}\n {% if doc.batch %}\n <div><strong>{{_(\"Batch\")}} </strong> {{doc.batch}}</div>\n {% endif %}\n \n {% if doc.information%} \n <div> {{doc.information}} </div>\n {% endif %} \n </div>\n <div class=\"right-wrapper\"> <img src=\"/files/hp_logo_black.jpg\" style=\"width: 30px;\"> </div>\n</div>\n{% else %} \n<div class=\"label-wrapper\">\n <div class=\"left-wrapper\">\n {% if doc.customer %} \n <h5 style=\"font-size: 40px;\"><strong>{{doc.customer}}</strong></h5>\n {% endif %}\n {% if doc.item_code %} \n <h4 style=\"font-size: 30px;\"><strong>{{doc.item_code}}</strong></h4>\n {% endif %}\n {% if doc.item_name%} \n <h5 style=\"font-size: 20px;\">{{doc.item_name}}</h5>\n {% endif %}\n \n {% if doc.batch %}\n <div><strong>{{_(\"Batch\")}} </strong> {{doc.batch}}</div>\n {% endif %}\n \n {% if doc.information%} \n <div> {{doc.information}} </div>\n {% endif %} \n </div>\n</div>\n{% endif %}\n",
|
||||||
"idx": 0,
|
"idx": 0,
|
||||||
"line_breaks": 0,
|
"line_breaks": 0,
|
||||||
"modified": "2022-04-03 14:52:16.543089",
|
"margin_bottom": 0.0,
|
||||||
|
"margin_left": 0.0,
|
||||||
|
"margin_right": 0.0,
|
||||||
|
"margin_top": 0.0,
|
||||||
|
"modified": "2023-08-28 13:06:58.300849",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Label Printing",
|
"module": "Label Printing",
|
||||||
"name": "Label",
|
"name": "Label",
|
||||||
"owner": "christian@prothmann.com",
|
"owner": "christian@prothmann.com",
|
||||||
"print_format_builder": 1,
|
"print_format_builder": 1,
|
||||||
|
"print_format_builder_beta": 0,
|
||||||
"print_format_type": "Jinja",
|
"print_format_type": "Jinja",
|
||||||
"raw_printing": 0,
|
"raw_printing": 0,
|
||||||
"show_section_headings": 0,
|
"show_section_headings": 0,
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
Label Printing
|
Label Printing
|
||||||
|
Scaled Pricing
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"js/label_printing.min.js": [
|
|
||||||
"public/js/label_printing_desk.js"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
2
label_printing/public/js/label_printing.bundle.js
Normal file
2
label_printing/public/js/label_printing.bundle.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import './label_printing_desk';
|
||||||
|
import './scaled_pricing';
|
||||||
@@ -32,10 +32,13 @@ function setupLabelsDialog(page) {
|
|||||||
title: __("Print Labels"),
|
title: __("Print Labels"),
|
||||||
fields: [{
|
fields: [{
|
||||||
label: __("Reference Doctype"),
|
label: __("Reference Doctype"),
|
||||||
options: ['Work Order', 'Item', 'Label'],
|
options: ['Work Order', 'Item', 'Label', 'Stock Entry'],
|
||||||
fieldname: 'doctype',
|
fieldname: 'doctype',
|
||||||
fieldtype: 'Select',
|
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"),
|
label: __("Get data"),
|
||||||
@@ -51,9 +54,9 @@ function setupLabelsDialog(page) {
|
|||||||
{
|
{
|
||||||
label: __("Reference Docname"),
|
label: __("Reference Docname"),
|
||||||
fieldname: 'docname',
|
fieldname: 'docname',
|
||||||
fieldtype: 'Data',
|
fieldtype: 'Link',
|
||||||
options: 'doctype',
|
options: cur_frm.doc.doctype,
|
||||||
default: fields.docname,
|
default: cur_frm.doc.name
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldtype: 'Section Break',
|
fieldtype: 'Section Break',
|
||||||
@@ -87,10 +90,29 @@ function setupLabelsDialog(page) {
|
|||||||
fieldname: 'batch',
|
fieldname: 'batch',
|
||||||
fieldtype: 'Data'
|
fieldtype: 'Data'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldtype: 'Section Break',
|
||||||
|
label: __('Printer')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: __("Printer Select"),
|
||||||
|
options: ['Labeldrucker Werk 1 (Ind. 6)', 'Labeldrucker Werk 2 (Bre. 19)'],
|
||||||
|
fieldname: 'printer_select',
|
||||||
|
fieldtype: 'Select',
|
||||||
|
default: 'Labeldrucker Werk 2 (Bre. 19)'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldtype: 'Section Break',
|
fieldtype: 'Section Break',
|
||||||
label: __('Labels')
|
label: __('Labels')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: __("Add Warehouse Label"),
|
||||||
|
fieldname: 'add_warehouse_label',
|
||||||
|
fieldtype: 'Button',
|
||||||
|
click: () => {
|
||||||
|
addWarehouseLabel()
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldname: "labels",
|
fieldname: "labels",
|
||||||
fieldtype: "Table",
|
fieldtype: "Table",
|
||||||
@@ -118,6 +140,12 @@ function setupLabelsDialog(page) {
|
|||||||
in_list_view: 1,
|
in_list_view: 1,
|
||||||
label: __('Information')
|
label: __('Information')
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: __("Is Warehouse Labael"),
|
||||||
|
fieldname: 'is_warehouse_label',
|
||||||
|
in_list_view: 1,
|
||||||
|
fieldtype: 'Check'
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -134,7 +162,9 @@ function setupLabelsDialog(page) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
d.hide();
|
d.hide();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
handleDataFetch();
|
handleDataFetch();
|
||||||
@@ -195,11 +225,42 @@ function setupLabelsDialog(page) {
|
|||||||
fields.customer = doc.associated_company
|
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)
|
d.set_values(fields)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addWarehouseLabel() {
|
||||||
|
fields = d.get_values()
|
||||||
|
let tempValues = d.get_values()
|
||||||
|
tempValues.labels.push({ item_qty: 0, label_qty: 1, is_warehouse_label: true })
|
||||||
|
console.log(tempValues)
|
||||||
|
d.fields_dict.labels.refresh()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_doc(doctype, docname) {
|
function get_doc(doctype, docname) {
|
||||||
|
|||||||
90
label_printing/public/js/scaled_pricing.js
Normal file
90
label_printing/public/js/scaled_pricing.js
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
const table_fields = [
|
||||||
|
{
|
||||||
|
fieldname: "min_qty",
|
||||||
|
fieldtype: "Float",
|
||||||
|
in_list_view: 1,
|
||||||
|
label: "Min Qty",
|
||||||
|
mandatory: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldname: "rate",
|
||||||
|
fieldtype: "Currency",
|
||||||
|
in_list_view: 1,
|
||||||
|
label: "Rate",
|
||||||
|
mandatory: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldname: "priority",
|
||||||
|
fieldtype: "Int",
|
||||||
|
in_list_view: 1,
|
||||||
|
label: "Priority",
|
||||||
|
read_only: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldname: "name",
|
||||||
|
fieldtype: "Link",
|
||||||
|
options: "Pricing Rule",
|
||||||
|
in_list_view: 1,
|
||||||
|
label: "Pricing Rule",
|
||||||
|
read_only: true
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
frappe.ui.form.on('Item', {
|
||||||
|
refresh(frm) {
|
||||||
|
frm.add_custom_button(__('Staggered Prices'), function () {
|
||||||
|
|
||||||
|
frappe.xcall('label_printing.scaled_pricing.scaled_pricing.get_price_lists', {
|
||||||
|
item_code: frm.doc.item_code
|
||||||
|
}).then((result) => {
|
||||||
|
generate_dialog(result, frm)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function generate_dialog(data, frm) {
|
||||||
|
let d = new frappe.ui.Dialog({
|
||||||
|
title: frm.doc.name,
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
fieldname: "scaled_prices",
|
||||||
|
fieldtype: "Table",
|
||||||
|
label: "Scaled Prices",
|
||||||
|
cannot_add_rows: false,
|
||||||
|
in_place_edit: true,
|
||||||
|
reqd: 0,
|
||||||
|
data: data,
|
||||||
|
fields: table_fields,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
size: 'large',
|
||||||
|
primary_action_label: 'Submit',
|
||||||
|
primary_action(values) {
|
||||||
|
if (values.scaled_prices.length > 20) {
|
||||||
|
frappe.throw(__('You can add a maximum of 20 Scaled Prices!'))
|
||||||
|
} else {
|
||||||
|
frappe.xcall('label_printing.scaled_pricing.scaled_pricing.change_price_lists', {
|
||||||
|
values: values,
|
||||||
|
frm: frm.doc.name
|
||||||
|
})
|
||||||
|
.then((result) => {
|
||||||
|
d.hide()
|
||||||
|
if (result === 200) {
|
||||||
|
frappe.show_alert({
|
||||||
|
message: __('Price Lists have been modified!'),
|
||||||
|
indicator: 'green'
|
||||||
|
}, 5);
|
||||||
|
d.hide();
|
||||||
|
} else {
|
||||||
|
frappe.throw(__("Couldn't change Pricelists!"))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
d.show();
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
/Volumes/development/frappe/frappe-bench/apps/label_printing/node_modules
|
/workspace/development/frappe-bench/apps/label_printing/node_modules
|
||||||
0
label_printing/scaled_pricing/__init__.py
Normal file
0
label_printing/scaled_pricing/__init__.py
Normal file
47
label_printing/scaled_pricing/scaled_pricing.py
Normal file
47
label_printing/scaled_pricing/scaled_pricing.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import frappe
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_price_lists(item_code):
|
||||||
|
pricing_rule_item_codes = frappe.db.get_all("Pricing Rule Item Code", filters={'item_code': item_code}, fields=["parent"])
|
||||||
|
|
||||||
|
pricing_rules = []
|
||||||
|
|
||||||
|
for item in pricing_rule_item_codes:
|
||||||
|
pricing_rule = frappe.get_doc('Pricing Rule', item.parent)
|
||||||
|
pricing_rules.append(pricing_rule)
|
||||||
|
|
||||||
|
|
||||||
|
return pricing_rules
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def change_price_lists(values, frm):
|
||||||
|
values = json.loads(values)
|
||||||
|
scaled_prices = values['scaled_prices']
|
||||||
|
|
||||||
|
scaled_prices = sorted(scaled_prices, key=lambda d: d['min_qty'])
|
||||||
|
|
||||||
|
for index, scaled_price in enumerate(scaled_prices):
|
||||||
|
doc = None
|
||||||
|
if frappe.db.exists('Pricing Rule', scaled_price["name"]):
|
||||||
|
doc = frappe.get_doc('Pricing Rule', scaled_price["name"])
|
||||||
|
|
||||||
|
else:
|
||||||
|
doc = frappe.new_doc('Pricing Rule')
|
||||||
|
doc.append("items", {
|
||||||
|
"item_code": frm,
|
||||||
|
"uom": "Stk"
|
||||||
|
})
|
||||||
|
doc.selling = 1
|
||||||
|
|
||||||
|
|
||||||
|
doc.min_qty = scaled_price["min_qty"]
|
||||||
|
doc.rate = scaled_price["rate"]
|
||||||
|
doc.title = "%s - %s" % (scaled_price["rate"], frm)
|
||||||
|
doc.priority = index + 1
|
||||||
|
|
||||||
|
doc.save()
|
||||||
|
|
||||||
|
return 200
|
||||||
Reference in New Issue
Block a user