diff --git a/erpnext/patches/v10_0/item_barcode_childtable_migrate.py b/erpnext/patches/v10_0/item_barcode_childtable_migrate.py index d36012ddd15..4194c873e6f 100644 --- a/erpnext/patches/v10_0/item_barcode_childtable_migrate.py +++ b/erpnext/patches/v10_0/item_barcode_childtable_migrate.py @@ -10,6 +10,7 @@ def execute(): items_barcode = frappe.db.sql("SELECT name, barcode FROM tabItem WHERE barcode IS NOT NULL", as_dict=1) for item in items_barcode: - doc = frappe.get_doc("Item", item.name) - doc.append("barcodes", {"barcode": item.get("barcode")}) - doc.save() + doc = frappe.get_doc("Item", item.get("name")) + if item.get("barcode"): + doc.append("barcodes", {"barcode": item.get("barcode")}) + doc.save()