Change DataMatrix to real Json

This commit is contained in:
BlubbFish 2026-02-19 23:51:57 +01:00
parent 1bacbae673
commit eae6fc8b3a
8 changed files with 185 additions and 102 deletions

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## 1.3.0 - 2026-02-19 - Change DataMatrix to real Json
### New Features
### Bugfixes
### Changes
* Change the Barcode to real json, so a , in a textfield not crashes the scanning.
* Change the LabelCount Collumn to a Checkbox. When checked it only printed one Label.
## 1.2.0 - 2026-02-18 - Fix Quantity on Labels so that you can recieve only partial deliverys ## 1.2.0 - 2026-02-18 - Fix Quantity on Labels so that you can recieve only partial deliverys
### New Features ### New Features
* Add a new Collumn to set the recieved Quantity on the Parts * Add a new Collumn to set the recieved Quantity on the Parts

View File

@ -13,7 +13,7 @@ namespace BlubbFish.Applications.Barcodes.Inventree {
label.DrawString(part.SKU, new Font("Arial", 10, FontStyle.Bold), Brushes.Black, 100, 33); label.DrawString(part.SKU, new Font("Arial", 10, FontStyle.Bold), Brushes.Black, 100, 33);
label.DrawString("Quantity", new Font("Arial", 6, FontStyle.Regular), Brushes.Black, 100, 48); label.DrawString("Quantity", new Font("Arial", 6, FontStyle.Regular), Brushes.Black, 100, 48);
label.DrawString(part.Quantity, new Font("Arial", 10, FontStyle.Bold), Brushes.Black, 100, 56); label.DrawString(part.Quantity.ToString(), new Font("Arial", 10, FontStyle.Bold), Brushes.Black, 100, 56);
label.DrawString("Position", new Font("Arial", 6, FontStyle.Regular), Brushes.Black, 100, 71); label.DrawString("Position", new Font("Arial", 6, FontStyle.Regular), Brushes.Black, 100, 71);
label.DrawString(part.CustomerPOLine, new Font("Arial", 10, FontStyle.Bold), Brushes.Black, 100, 79); label.DrawString(part.CustomerPOLine, new Font("Arial", 10, FontStyle.Bold), Brushes.Black, 100, 79);

View File

@ -53,12 +53,6 @@
this.buttonNone = new Button(); this.buttonNone = new Button();
this.buttonAll = new Button(); this.buttonAll = new Button();
this.dataGridView1 = new DataGridView(); this.dataGridView1 = new DataGridView();
this.Column4 = new DataGridViewTextBoxColumn();
this.Column1 = new DataGridViewCheckBoxColumn();
this.Column6 = new DataGridViewTextBoxColumn();
this.Column2 = new DataGridViewTextBoxColumn();
this.Column3 = new DataGridViewTextBoxColumn();
this.Got = new DataGridViewTextBoxColumn();
this._textServerName = new Label(); this._textServerName = new Label();
this.label8 = new Label(); this.label8 = new Label();
this._textPrinterName = new Label(); this._textPrinterName = new Label();
@ -70,6 +64,12 @@
this.Druckereinstellungen = new TabPage(); this.Druckereinstellungen = new TabPage();
this._checkBox_Landscape = new CheckBox(); this._checkBox_Landscape = new CheckBox();
this._buttonSaveSettings2 = new Button(); this._buttonSaveSettings2 = new Button();
this.Pos = new DataGridViewTextBoxColumn();
this.Print = new DataGridViewCheckBoxColumn();
this.Bag = new DataGridViewCheckBoxColumn();
this.Teil = new DataGridViewTextBoxColumn();
this.Sku = new DataGridViewTextBoxColumn();
this.Got = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)this.pictureBox1).BeginInit(); ((System.ComponentModel.ISupportInitialize)this.pictureBox1).BeginInit();
this.statusStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout();
this._mainTabBox.SuspendLayout(); this._mainTabBox.SuspendLayout();
@ -317,7 +317,7 @@
this.dataGridView1.AllowUserToDeleteRows = false; this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.AllowUserToResizeRows = false; this.dataGridView1.AllowUserToResizeRows = false;
this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new DataGridViewColumn[] { this.Column4, this.Column1, this.Column6, this.Column2, this.Column3, this.Got }); this.dataGridView1.Columns.AddRange(new DataGridViewColumn[] { this.Pos, this.Print, this.Bag, this.Teil, this.Sku, this.Got });
this.dataGridView1.EditMode = DataGridViewEditMode.EditOnKeystroke; this.dataGridView1.EditMode = DataGridViewEditMode.EditOnKeystroke;
this.dataGridView1.Location = new Point(6, 40); this.dataGridView1.Location = new Point(6, 40);
this.dataGridView1.MultiSelect = false; this.dataGridView1.MultiSelect = false;
@ -331,55 +331,6 @@
this.dataGridView1.CellValueChanged += this.DataGridView1_CellValueChanged; this.dataGridView1.CellValueChanged += this.DataGridView1_CellValueChanged;
this.dataGridView1.SelectionChanged += this.DataGridView1_SelectionChanged; this.dataGridView1.SelectionChanged += this.DataGridView1_SelectionChanged;
// //
// Column4
//
this.Column4.HeaderText = "Pos";
this.Column4.MinimumWidth = 45;
this.Column4.Name = "Column4";
this.Column4.ReadOnly = true;
this.Column4.Resizable = DataGridViewTriState.False;
this.Column4.Width = 45;
//
// Column1
//
this.Column1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
this.Column1.HeaderText = "Drucken";
this.Column1.MinimumWidth = 70;
this.Column1.Name = "Column1";
this.Column1.Resizable = DataGridViewTriState.False;
this.Column1.Width = 70;
//
// Column6
//
this.Column6.HeaderText = "Labels";
this.Column6.MinimumWidth = 60;
this.Column6.Name = "Column6";
this.Column6.SortMode = DataGridViewColumnSortMode.NotSortable;
this.Column6.Width = 60;
//
// Column2
//
this.Column2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
this.Column2.HeaderText = "Teil";
this.Column2.MinimumWidth = 300;
this.Column2.Name = "Column2";
this.Column2.ReadOnly = true;
//
// Column3
//
this.Column3.HeaderText = "SKU";
this.Column3.MinimumWidth = 150;
this.Column3.Name = "Column3";
this.Column3.ReadOnly = true;
this.Column3.Width = 150;
//
// Got
//
this.Got.HeaderText = "Got";
this.Got.MinimumWidth = 50;
this.Got.Name = "Got";
this.Got.Width = 50;
//
// _textServerName // _textServerName
// //
this._textServerName.AutoSize = true; this._textServerName.AutoSize = true;
@ -499,6 +450,55 @@
this._buttonSaveSettings2.UseVisualStyleBackColor = true; this._buttonSaveSettings2.UseVisualStyleBackColor = true;
this._buttonSaveSettings2.Click += this.ButtonSaveSettings_Click; this._buttonSaveSettings2.Click += this.ButtonSaveSettings_Click;
// //
// Pos
//
this.Pos.HeaderText = "Pos";
this.Pos.MinimumWidth = 45;
this.Pos.Name = "Pos";
this.Pos.ReadOnly = true;
this.Pos.Resizable = DataGridViewTriState.False;
this.Pos.Width = 45;
//
// Print
//
this.Print.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
this.Print.HeaderText = "Drucken";
this.Print.MinimumWidth = 70;
this.Print.Name = "Print";
this.Print.Resizable = DataGridViewTriState.False;
this.Print.Width = 70;
//
// Bag
//
this.Bag.HeaderText = "Bag";
this.Bag.MinimumWidth = 60;
this.Bag.Name = "Bag";
this.Bag.Resizable = DataGridViewTriState.True;
this.Bag.Width = 60;
//
// Teil
//
this.Teil.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
this.Teil.HeaderText = "Teil";
this.Teil.MinimumWidth = 300;
this.Teil.Name = "Teil";
this.Teil.ReadOnly = true;
//
// Sku
//
this.Sku.HeaderText = "SKU";
this.Sku.MinimumWidth = 150;
this.Sku.Name = "Sku";
this.Sku.ReadOnly = true;
this.Sku.Width = 150;
//
// Got
//
this.Got.HeaderText = "Got";
this.Got.MinimumWidth = 50;
this.Got.Name = "Got";
this.Got.Width = 50;
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new SizeF(8F, 20F); this.AutoScaleDimensions = new SizeF(8F, 20F);
@ -565,11 +565,11 @@
private Button buttonNone; private Button buttonNone;
private Button buttonAll; private Button buttonAll;
private Label labelCount; private Label labelCount;
private DataGridViewTextBoxColumn Column4; private DataGridViewTextBoxColumn Pos;
private DataGridViewCheckBoxColumn Column1; private DataGridViewCheckBoxColumn Print;
private DataGridViewTextBoxColumn Column6; private DataGridViewCheckBoxColumn Bag;
private DataGridViewTextBoxColumn Column2; private DataGridViewTextBoxColumn Teil;
private DataGridViewTextBoxColumn Column3; private DataGridViewTextBoxColumn Sku;
private DataGridViewTextBoxColumn Got; private DataGridViewTextBoxColumn Got;
} }
} }

View File

@ -257,14 +257,13 @@ namespace BlubbFish.Applications.Barcodes.Inventree {
private void PreparePintList() { private void PreparePintList() {
this.printList.Clear(); this.printList.Clear();
foreach(DataGridViewRow item in this.dataGridView1.Rows) { foreach(DataGridViewRow item in this.dataGridView1.Rows) {
if(item.Cells[1].Value is Boolean b) { if(item.Cells[1].Value is Boolean print) {
if(b && Int32.TryParse(item.Cells[2].Value.ToString(), out Int32 c) && c > 0) { if(print && item.Cells[2].Value is Boolean bag) {
if(item.Cells[3].Value is LineItem l) { if(item.Cells[3].Value is LineItem l) {
for(Int32 i = 0; i < c; i++) { if(Double.TryParse(item.Cells[5].Value.ToString(), out Double q)) {
for(Int32 i = 0; i < Convert.ToInt32(bag ? 1 : q); i++) {
Ecia t = l.EciaFormat; Ecia t = l.EciaFormat;
if(Int32.TryParse(item.Cells[5].Value.ToString(), out Int32 q)) { t.Quantity = q;
t.Quantity = q.ToString();
}
this.printList.Enqueue(t); this.printList.Enqueue(t);
} }
} }
@ -272,7 +271,7 @@ namespace BlubbFish.Applications.Barcodes.Inventree {
} }
} }
} }
}
private void ButtonPrint_Click(Object sender, EventArgs e) { private void ButtonPrint_Click(Object sender, EventArgs e) {
this.PreparePintList(); this.PreparePintList();
this.printDocument1.Print(); this.printDocument1.Print();
@ -359,12 +358,12 @@ namespace BlubbFish.Applications.Barcodes.Inventree {
DataGridViewRow r = new(); DataGridViewRow r = new();
r.CreateCells(this.dataGridView1); r.CreateCells(this.dataGridView1);
Int32 recieved = Convert.ToInt32(Double.Parse(item["received"].ToString())); Double recieved = Double.Parse(item["received"].ToString());
Int32 quantity = Convert.ToInt32(Double.Parse(item["quantity"].ToString())); Double quantity = Double.Parse(item["quantity"].ToString());
r.Cells[0].Value = i; r.Cells[0].Value = i;
r.Cells[1].Value = quantity > recieved; r.Cells[1].Value = quantity > recieved;
r.Cells[2].Value = quantity >= recieved ? quantity - recieved : 0; r.Cells[2].Value = false;
r.Cells[3].Value = new LineItem { r.Cells[3].Value = new LineItem {
Name = item["internal_part_name"].ToString(), Name = item["internal_part_name"].ToString(),
SKU = item["sku"].ToString(), SKU = item["sku"].ToString(),
@ -373,12 +372,12 @@ namespace BlubbFish.Applications.Barcodes.Inventree {
Quantity = quantity, Quantity = quantity,
EciaFormat = new Ecia { EciaFormat = new Ecia {
CustomerPO = po.Reference, CustomerPO = po.Reference,
PackageId = po.SupplierReference, SupplierOrderNumber = po.SupplierReference,
ShipDate = DateTime.Now.ToString("yyyyMMdd"), ShipDate = DateTime.Now.ToString("yyyyMMdd"),
SKU = item["sku"].ToString(), SKU = item["sku"].ToString(),
MPN = item["mpn"].ToString(), MPN = item["mpn"].ToString(),
CustomerPOLine = i++.ToString(), CustomerPOLine = i++.ToString(),
Quantity = quantity.ToString(), Quantity = quantity,
DateCode = DateTime.Now.ToString("yy01"), DateCode = DateTime.Now.ToString("yy01"),
LotCode = "1", LotCode = "1",
County = "DE" County = "DE"
@ -404,9 +403,11 @@ namespace BlubbFish.Applications.Barcodes.Inventree {
private void CalcLabelCount() { private void CalcLabelCount() {
Int32 i = 0; Int32 i = 0;
foreach(DataGridViewRow item in this.dataGridView1.Rows) { foreach(DataGridViewRow item in this.dataGridView1.Rows) {
if(item.Cells[1].Value is Boolean b) { if(item.Cells[1].Value is Boolean print) {
if(b && Int32.TryParse(item.Cells[2].Value.ToString(), out Int32 c)) { if(print && Double.TryParse(item.Cells[5].Value.ToString(), out Double c)) {
i += c; if(item.Cells[2].Value is Boolean bag) {
i += Convert.ToInt32(bag ? 1 : c);
}
} }
} }
} }
@ -419,8 +420,8 @@ namespace BlubbFish.Applications.Barcodes.Inventree {
if(this.dataGridView1.Rows.Count >= i) { if(this.dataGridView1.Rows.Count >= i) {
if(this.dataGridView1.Rows[i].Cells[3].Value is LineItem l) { if(this.dataGridView1.Rows[i].Cells[3].Value is LineItem l) {
this.part = l.EciaFormat; this.part = l.EciaFormat;
if(Int32.TryParse(this.dataGridView1.Rows[i].Cells[5].Value.ToString(), out Int32 c)) { if(Double.TryParse(this.dataGridView1.Rows[i].Cells[5].Value.ToString(), out Double c)) {
this.part.Quantity = c.ToString(); this.part.Quantity = c;
} }
this.DrawPreview(); this.DrawPreview();
} }

View File

@ -150,19 +150,19 @@
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>561, 17</value> <value>561, 17</value>
</metadata> </metadata>
<metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Pos.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Print.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Bag.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Teil.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Sku.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="Got.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="Got.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@ -9,7 +9,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<AssemblyVersion>1.2.0</AssemblyVersion> <AssemblyVersion>1.3.0</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion> <FileVersion>$(AssemblyVersion)</FileVersion>
<Version>$(AssemblyVersion)</Version> <Version>$(AssemblyVersion)</Version>
<Authors>BlubbFish</Authors> <Authors>BlubbFish</Authors>
@ -24,6 +24,7 @@
<RepositoryUrl>https://git.blubbfish.net/vs_projects/InventreeBarcodeGenerator.git</RepositoryUrl> <RepositoryUrl>https://git.blubbfish.net/vs_projects/InventreeBarcodeGenerator.git</RepositoryUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<PackageReleaseNotes> <PackageReleaseNotes>
1.3.0 - 2026-02-19 - Change DataMatrix to real Json
1.2.0 - 2026-02-18 - Fix Quantity on Labels so that you can recieve only partial deliverys 1.2.0 - 2026-02-18 - Fix Quantity on Labels so that you can recieve only partial deliverys
1.1.0 - 2026-02-14 - Rewrote to DataGridView 1.1.0 - 2026-02-14 - Rewrote to DataGridView
1.0.0 - 2025-11-23 - Init 1.0.0 - 2025-11-23 - Init

View File

@ -1,9 +1,11 @@
namespace BlubbFish.Applications.Barcodes.Inventree.Models { using LitJson;
namespace BlubbFish.Applications.Barcodes.Inventree.Models {
internal class Ecia { internal class Ecia {
public String CustomerPO { public String CustomerPO {
get; set; get; set;
} }
public String PackageId { public String SupplierOrderNumber {
get; set; get; set;
} }
public String ShipDate { public String ShipDate {
@ -18,7 +20,7 @@
public String CustomerPOLine { public String CustomerPOLine {
get; set; get; set;
} }
public String Quantity { public Double Quantity {
get; set; get; set;
} }
public String DateCode { public String DateCode {
@ -31,17 +33,18 @@
get; set; get; set;
} }
public override String ToString() => this.Quantity + "x " + this.SKU + " from " + this.CustomerPO; public override String ToString() => this.Quantity + "x " + this.SKU + " from " + this.CustomerPO;
public String ToEciaString() => "{" + public String ToEciaString() => JsonMapper.ToJson(new Dictionary<String, Object>() {
"K" + ":" + this.CustomerPO + "," + { "K", this.CustomerPO },
"4S" + ":" + this.PackageId + "," + { "1K", this.SupplierOrderNumber},
"6D" + ":" + this.ShipDate + "," + { "6D", this.ShipDate},
"P" + ":" + this.SKU + "," + { "P", this.SKU},
"1P" + ":" + this.MPN + "," + { "1P", this.MPN},
"4K" + ":" + this.CustomerPOLine + "," + { "4K", this.CustomerPOLine},
"Q" + ":" + this.Quantity + "," + { "Q", this.Quantity},
"10D" + ":" + this.DateCode + "," + { "10D", this.DateCode},
"1T" + ":" + this.LotCode + "," + { "1T", this.LotCode},
"4L" + ":" + this.County + { "4L", this.County},
"}";
});
} }
} }

View File

@ -0,0 +1,71 @@
"""The BarcodePlugin is meant to integrate the Barcodes into InvenTree.
This plugin can currently only match barcodes to supplier parts.
"""
import re
import json
from django.utils.translation import gettext_lazy as _
from plugin import InvenTreePlugin
from plugin.mixins import SettingsMixin, SupplierBarcodeMixin
class ReicheltPlugin(SupplierBarcodeMixin, SettingsMixin, InvenTreePlugin):
"""Plugin to integrate the Barcodes into InvenTree."""
NAME = 'ReicheltBarcodePlugin'
SLUG = 'Reicheltplugin'
TITLE = _('Supplier Integration - Reichelt')
DESCRIPTION = _('Provides support for scanning Reichelt barcodes')
VERSION = '1.0.0'
AUTHOR = _('BlubbFish')
DEFAULT_SUPPLIER_NAME = 'Reichelt'
SETTINGS = {
'SUPPLIER_ID': {
'name': _('Supplier'),
'description': _("The Supplier which acts as 'Reichelt'"),
'model': 'company.company',
'model_filters': {'is_supplier': True},
}
}
# Custom field mapping for LCSC barcodes
BARCODE_FIELDS = {
'K': SupplierBarcodeMixin.CUSTOMER_ORDER_NUMBER,
'1K': SupplierBarcodeMixin.SUPPLIER_ORDER_NUMBER,
'11K': SupplierBarcodeMixin.PACKING_LIST_NUMBER,
'6D': SupplierBarcodeMixin.SHIP_DATE,
'9D': SupplierBarcodeMixin.DATE_CODE,
'10D': SupplierBarcodeMixin.DATE_CODE,
'4K': SupplierBarcodeMixin.PURCHASE_ORDER_LINE,
'14K': SupplierBarcodeMixin.PURCHASE_ORDER_LINE,
'P': SupplierBarcodeMixin.SUPPLIER_PART_NUMBER,
'1P': SupplierBarcodeMixin.MANUFACTURER_PART_NUMBER,
'30P': SupplierBarcodeMixin.SUPPLIER_PART_NUMBER,
'1T': SupplierBarcodeMixin.LOT_CODE,
'4L': SupplierBarcodeMixin.COUNTRY_OF_ORIGIN,
'1V': SupplierBarcodeMixin.MANUFACTURER,
'Q': SupplierBarcodeMixin.QUANTITY,
}
def extract_barcode_fields(self, barcode_data: str) -> dict[str, str]:
"""Get supplier_part and barcode_fields from LCSC QR-Code.
Example QR-Code: {"K":"KA-0077","1K":"028-3720301-6481114","6D":"20260219","P":"B0977HLT4P","1P":"SDCZ48-064G-G46T","4K":"1","Q":0.0,"10D":"2601","1T":"1","4L":"DE"}
"""
try:
jsonData = json.loads(barcode_data)
except ValueError as err:
return {}
barcode_fields = {}
# Map from LCSC field names to standard field names
for key, field in self.BARCODE_FIELDS.items():
if key in jsonData.keys():
barcode_fields[field] = jsonData[key]
return barcode_fields