mirror of
https://github.com/itsdave-de/msp.git
synced 2025-05-06 15:35:12 +02:00
QR code dunctionality
This commit is contained in:
parent
94e705962f
commit
6a3e6308f3
@ -20,7 +20,9 @@ app_include_js = "/assets/msp/js/customer_quick_entry.js"
|
||||
|
||||
jenv = {
|
||||
"methods": [
|
||||
"jinja_get_item_price:msp.things.get_item_price_for_label"
|
||||
"jinja_get_item_price:msp.things.get_item_price_for_label",
|
||||
"jinja_get_epc_code:msp.things.get_epc_inline",
|
||||
"jinja_get_qr_code:msp.things.get_qr_code_inline"
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,10 @@
|
||||
"field_order": [
|
||||
"open_it_cockpit_integration_section",
|
||||
"oitc_url",
|
||||
"oitc_api_key"
|
||||
"oitc_api_key",
|
||||
"qr_code_settings_section",
|
||||
"qr_code_dark_color",
|
||||
"qr_code_scale"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@ -25,12 +28,27 @@
|
||||
"fieldname": "oitc_api_key",
|
||||
"fieldtype": "Password",
|
||||
"label": "OITC API Key"
|
||||
},
|
||||
{
|
||||
"fieldname": "qr_code_settings_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "QR Code Settings"
|
||||
},
|
||||
{
|
||||
"fieldname": "qr_code_dark_color",
|
||||
"fieldtype": "Color",
|
||||
"label": "QR Code Dark Color"
|
||||
},
|
||||
{
|
||||
"fieldname": "qr_code_scale",
|
||||
"fieldtype": "Int",
|
||||
"label": "QR Code Scale"
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2022-07-18 10:23:49.010330",
|
||||
"modified": "2022-07-18 10:53:35.413597",
|
||||
"modified_by": "Administrator",
|
||||
"module": "MSP",
|
||||
"name": "MSP Settings",
|
||||
|
@ -1,5 +1,7 @@
|
||||
from this import d
|
||||
from erpnext.stock.doctype import item
|
||||
import frappe
|
||||
import re
|
||||
|
||||
|
||||
def set_item_group_warehouse():
|
||||
@ -47,7 +49,48 @@ def get_warehouse_for_label(item_code):
|
||||
return
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_qr_code(data, format=None):
|
||||
def get_epc_inline(name, iban, amount, text, color_dark=None, scale=None):
|
||||
from segno import helpers
|
||||
settings = frappe.get_single("MSP Settings")
|
||||
#determinate color
|
||||
if color_dark:
|
||||
m = re.match("(#\d{3}|#\d{6})", color_dark)
|
||||
if m:
|
||||
color_dark = m[1]
|
||||
else:
|
||||
if settings.qr_code_dark_color:
|
||||
color_dark = settings.qr_code_dark_color
|
||||
else:
|
||||
color_dark = "#333A3F"
|
||||
#determinate Scale
|
||||
if not scale:
|
||||
scale = settings.qr_code_scale if settings.qr_code_scale else 1
|
||||
|
||||
qrcode = helpers.make_epc_qr(
|
||||
name=name,
|
||||
iban=iban,
|
||||
amount=amount,
|
||||
text=text)
|
||||
return qrcode.svg_inline(dark=color_dark, scale=scale)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_qr_code_inline(data, color_dark=None, scale=None):
|
||||
import segno
|
||||
|
||||
settings = frappe.get_single("MSP Settings")
|
||||
#determinate color
|
||||
if color_dark:
|
||||
m = re.match("(#\d{3}|#\d{6})", color_dark)
|
||||
if m:
|
||||
color_dark = m[1]
|
||||
else:
|
||||
if settings.qr_code_dark_color:
|
||||
color_dark = settings.qr_code_dark_color
|
||||
else:
|
||||
color_dark = "#333A3F"
|
||||
#determinate Scale
|
||||
if not scale:
|
||||
scale = settings.qr_code_scale if settings.qr_code_scale else 1
|
||||
scale = float(scale)
|
||||
qrcode = segno.make(data)
|
||||
return qrcode.svg_inline(dark=color_dark, scale=scale)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user