2017-12-11 09:54:18 +01:00
|
|
|
# Copyright (c) 2017, Frappe and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
|
|
|
|
import frappe
|
|
|
|
|
|
|
|
|
|
|
|
def execute():
|
2019-02-17 11:24:51 +05:30
|
|
|
frappe.reload_doc("stock", "doctype", "item_barcode")
|
2019-06-28 12:46:42 +05:30
|
|
|
if frappe.get_all("Item Barcode", limit=1):
|
|
|
|
return
|
|
|
|
if "barcode" not in frappe.db.get_table_columns("Item"):
|
|
|
|
return
|
2022-03-28 18:52:46 +05:30
|
|
|
|
2019-06-28 12:46:42 +05:30
|
|
|
items_barcode = frappe.db.sql(
|
|
|
|
"select name, barcode from tabItem where barcode is not null", as_dict=True
|
|
|
|
)
|
2018-02-12 15:59:55 +05:30
|
|
|
frappe.reload_doc("stock", "doctype", "item")
|
2019-02-17 11:24:51 +05:30
|
|
|
|
2018-02-12 15:59:55 +05:30
|
|
|
for item in items_barcode:
|
2018-02-23 16:19:41 +05:30
|
|
|
barcode = item.barcode.strip()
|
|
|
|
|
|
|
|
if barcode and "<" not in barcode:
|
2019-02-16 21:09:24 +05:30
|
|
|
try:
|
|
|
|
frappe.get_doc(
|
|
|
|
{
|
|
|
|
"idx": 0,
|
|
|
|
"doctype": "Item Barcode",
|
|
|
|
"barcode": barcode,
|
|
|
|
"parenttype": "Item",
|
|
|
|
"parent": item.name,
|
|
|
|
"parentfield": "barcodes",
|
|
|
|
}
|
|
|
|
).insert()
|
2019-03-08 10:44:13 +05:30
|
|
|
except (frappe.DuplicateEntryError, frappe.UniqueValidationError):
|
2019-02-16 21:09:24 +05:30
|
|
|
continue
|