diff --git a/posnext/doc_events/item.py b/posnext/doc_events/item.py
index b1bc32e..eefd491 100644
--- a/posnext/doc_events/item.py
+++ b/posnext/doc_events/item.py
@@ -1,5 +1,10 @@
import frappe
-
+from frappe import _
+from frappe.utils.pdf import get_pdf
+from frappe.www.printview import get_context
+import json
+from frappe.utils import now
+from frappe.utils.file_manager import save_file
def validate_item(doc, method):
for x in doc.custom_items:
@@ -29,4 +34,50 @@ def get_product_bundle_with_items(item_code):
"name": bundle_doc.name,
"new_item_code": bundle_doc.new_item_code,
"items": bundle_items
+ }
+
+
+@frappe.whitelist()
+def print_barcodes(item_codes):
+ if isinstance(item_codes, str):
+
+ item_codes = json.loads(item_codes)
+
+
+ items_with_barcodes = [
+ frappe.get_doc("Item", code)
+ for code in item_codes
+ if frappe.get_doc("Item", code).barcodes
+ ]
+
+ if not items_with_barcodes:
+ frappe.throw(_("No items with barcodes found"))
+
+ print_format = "Barcode Print"
+
+ if len(items_with_barcodes) == 1:
+ item_name = items_with_barcodes[0].name
+ url = f"/printview?doctype=Item&name={item_name}&format={print_format}&no_letterhead=1"
+ return {"url": url}
+
+ html_content = ''.join(
+ f'
{frappe.get_print("Item", item.name, print_format, doc=item)}
'
+ for item in items_with_barcodes
+ )
+
+ pdf_data = get_pdf(html_content)
+
+ file_name = f"Multiple_Barcodes_{now().replace(' ', '_').replace(':', '-')}.pdf"
+ file_doc = save_file(
+ fname=file_name,
+ content=pdf_data,
+ dt="Item",
+ dn=items_with_barcodes[0].name,
+ is_private=0
+ )
+
+ return {
+ "url": file_doc.file_url,
+ "message": _(f"Generated barcodes for {len(items_with_barcodes)} items."),
+ "is_pdf": True
}
\ No newline at end of file
diff --git a/posnext/hooks.py b/posnext/hooks.py
index 3d6c6b6..9bc76bb 100644
--- a/posnext/hooks.py
+++ b/posnext/hooks.py
@@ -41,7 +41,7 @@
# include js in doctype views
doctype_js = {"POS Profile" : "public/js/pos_profile.js"}
-# doctype_list_js = {"doctype" : "public/js/doctype_list.js"}
+doctype_list_js = {"Item" : "public/js/item_list.js"}
# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"}
# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"}
diff --git a/posnext/posnext/print_format/__init__.py b/posnext/posnext/print_format/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/posnext/posnext/print_format/barcode_print/__init__.py b/posnext/posnext/print_format/barcode_print/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/posnext/posnext/print_format/barcode_print/barcode_print.json b/posnext/posnext/print_format/barcode_print/barcode_print.json
new file mode 100644
index 0000000..5f6ed82
--- /dev/null
+++ b/posnext/posnext/print_format/barcode_print/barcode_print.json
@@ -0,0 +1,31 @@
+{
+ "absolute_value": 0,
+ "align_labels_right": 0,
+ "creation": "2025-04-29 14:04:26.038617",
+ "custom_format": 1,
+ "default_print_language": "en-US",
+ "disabled": 0,
+ "doc_type": "Item",
+ "docstatus": 0,
+ "doctype": "Print Format",
+ "font_size": 14,
+ "html": "\n\n\n \n Barcode Label\n \n\n\n\n \n
\n {{ doc.item_name or doc.name }}\n
\n\n
\n {% set batch_id = frappe.db.get_value(\"Item Barcode\", {\"parent\": doc.name}, \"barcode\") %}\n

\n
\n\n \n
\n\n\n\n",
+ "idx": 0,
+ "line_breaks": 0,
+ "margin_bottom": 15.0,
+ "margin_left": 15.0,
+ "margin_right": 15.0,
+ "margin_top": 15.0,
+ "modified": "2025-04-29 14:51:39.357708",
+ "modified_by": "Administrator",
+ "module": "Posnext",
+ "name": "Barcode Print",
+ "owner": "Administrator",
+ "page_number": "Hide",
+ "print_format_builder": 0,
+ "print_format_builder_beta": 0,
+ "print_format_type": "Jinja",
+ "raw_printing": 0,
+ "show_section_headings": 0,
+ "standard": "Yes"
+}
\ No newline at end of file
diff --git a/posnext/posnext/print_format/print_barcodes/__init__.py b/posnext/posnext/print_format/print_barcodes/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/posnext/posnext/print_format/print_barcodes/print_barcodes.json b/posnext/posnext/print_format/print_barcodes/print_barcodes.json
new file mode 100644
index 0000000..caa8686
--- /dev/null
+++ b/posnext/posnext/print_format/print_barcodes/print_barcodes.json
@@ -0,0 +1,31 @@
+{
+ "absolute_value": 0,
+ "align_labels_right": 0,
+ "creation": "2025-04-29 11:29:57.511867",
+ "custom_format": 1,
+ "default_print_language": "en-US",
+ "disabled": 0,
+ "doc_type": "Item",
+ "docstatus": 0,
+ "doctype": "Print Format",
+ "font_size": 14,
+ "html": "\n\n\n Barcode Print\n\n\n Barcode Print
\n \n \n \n | Item Code | \n Item Name | \n Barcode | \n
\n \n \n {% for b in barcodes %}\n \n | {{ b.item_code }} | \n {{ b.item_name }} | \n  | \n
\n {% endfor %}\n \n
\n\n\n",
+ "idx": 0,
+ "line_breaks": 0,
+ "margin_bottom": 15.0,
+ "margin_left": 15.0,
+ "margin_right": 15.0,
+ "margin_top": 15.0,
+ "modified": "2025-04-29 11:29:57.511867",
+ "modified_by": "Administrator",
+ "module": "Posnext",
+ "name": "Print Barcodes",
+ "owner": "Administrator",
+ "page_number": "Hide",
+ "print_format_builder": 0,
+ "print_format_builder_beta": 0,
+ "print_format_type": "Jinja",
+ "raw_printing": 0,
+ "show_section_headings": 0,
+ "standard": "Yes"
+}
\ No newline at end of file
diff --git a/posnext/public/js/item_list.js b/posnext/public/js/item_list.js
new file mode 100644
index 0000000..ccfdefc
--- /dev/null
+++ b/posnext/public/js/item_list.js
@@ -0,0 +1,27 @@
+frappe.listview_settings['Item'] = frappe.listview_settings['Item'] || {};
+
+frappe.listview_settings['Item'].onload = function(listview) {
+ listview.page.add_actions_menu_item(__('Barcode Print'), function() {
+ const selected_docs = listview.get_checked_items();
+
+ if (!selected_docs.length) {
+ frappe.msgprint(__('Please select at least one Item'));
+ return;
+ }
+
+ const item_codes = selected_docs.map(doc => doc.name);
+
+ frappe.call({
+ method: 'posnext.doc_events.item.print_barcodes',
+ args: { item_codes },
+ callback: function(r) {
+ if (r.message && r.message.url) {
+ window.open(r.message.url, '_blank');
+ } else {
+ frappe.msgprint(__('Could not generate barcode print URL.'));
+ }
+ }
+ });
+ });
+};
+