e6236094a6
* fix(item): fix patch for barcode childtable migration in item (cherry picked from commit b2c43ee2d91599038f7bdf2038bbc4c4e7b36285) * fix(item): fixing broken patch item_barcode_childtable_migrate (cherry picked from commit beca677276e0b5b143cd6d1d08efa8529663f60c)
34 lines
891 B
Python
34 lines
891 B
Python
# Copyright (c) 2017, Frappe and Contributors
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import frappe
|
|
|
|
|
|
def execute():
|
|
frappe.reload_doc("stock", "doctype", "item_barcode")
|
|
if frappe.get_all("Item Barcode", limit=1): return
|
|
if "barcode" not in frappe.db.get_table_columns("Item"): return
|
|
|
|
items_barcode = frappe.db.sql("select name, barcode from tabItem where barcode is not null", as_dict=True)
|
|
frappe.reload_doc("stock", "doctype", "item")
|
|
|
|
|
|
|
|
for item in items_barcode:
|
|
barcode = item.barcode.strip()
|
|
|
|
if barcode and '<' not in barcode:
|
|
try:
|
|
frappe.get_doc({
|
|
'idx': 0,
|
|
'doctype': 'Item Barcode',
|
|
'barcode': barcode,
|
|
'parenttype': 'Item',
|
|
'parent': item.name,
|
|
'parentfield': 'barcodes'
|
|
}).insert()
|
|
except (frappe.DuplicateEntryError, frappe.UniqueValidationError):
|
|
continue
|