Compare commits
8 Commits
baceb8fb66
...
version-15
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d1cfdb88a | |||
| 3664311505 | |||
| 3ea3ed2e02 | |||
| 33cefa96e1 | |||
| 155d7a9a7c | |||
| 6a6212e163 | |||
| 494c7d622f | |||
|
|
10ffbf0f44 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -16,4 +16,6 @@ __pycache__
|
||||
.idea/
|
||||
.vscode/
|
||||
node_modules/
|
||||
.backportrc.json
|
||||
.backportrc.json
|
||||
label_printing/public/node_modules
|
||||
*/node_modules/*
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
|
||||
__version__ = '0.0.1'
|
||||
|
||||
__version__ = '14.38.0'
|
||||
|
||||
@@ -4,8 +4,7 @@ import frappe
|
||||
import os
|
||||
import json
|
||||
from frappe import _
|
||||
|
||||
from PyPDF2 import PdfWriter
|
||||
from pypdf import PdfWriter
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
@@ -31,6 +30,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()
|
||||
|
||||
@@ -83,14 +84,4 @@ def print_label_by_server(doctype, name, qty, printer_setting, print_format=None
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_associated_stockentry(workorder):
|
||||
return frappe.get_last_doc('Stock Entry', filters={"work_order": workorder})
|
||||
|
||||
# @frappe.whitelist()
|
||||
# def get_label_printers():
|
||||
# label_printing_settings = frappe.get_doc('Label Printing Settings')
|
||||
# label_printer_names = []
|
||||
#
|
||||
# for x in label_printing_settings.label_printers:
|
||||
# label_printer_names.append(x.label_printer)
|
||||
#
|
||||
# return(label_printer_names)
|
||||
return frappe.get_last_doc('Stock Entry', filters={"work_order": workorder})
|
||||
@@ -7,9 +7,6 @@ import json
|
||||
def create_labels(values):
|
||||
|
||||
values = json.loads(values)
|
||||
print(values)
|
||||
|
||||
print(values["item_code"])
|
||||
|
||||
doc = frappe.new_doc('Label')
|
||||
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_mandatory=True # insert even if mandatory fields are not set
|
||||
)
|
||||
print(res)
|
||||
|
||||
# print_by_server("Label", "Label-00001", "labelprinter", "Labels")
|
||||
return 200
|
||||
|
||||
@@ -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": []
|
||||
}
|
||||
@@ -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<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 %}",
|
||||
"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,
|
||||
"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",
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
Label Printing
|
||||
Label Printing
|
||||
Scaled Pricing
|
||||
@@ -1 +1,2 @@
|
||||
import './label_printing_desk';
|
||||
import './label_printing_desk';
|
||||
import './scaled_pricing';
|
||||
@@ -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',
|
||||
@@ -104,6 +105,14 @@ function setupLabelsDialog(page) {
|
||||
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,42 @@ 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 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) {
|
||||
|
||||
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 @@
|
||||
/home/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