brotherton-erpnext/erpnext/patches/v10_0/item_barcode_childtable_migrate.py
Faris Ansari 97b212e348 Patch optimization (#13060)
* Patch fixes

* fix codacy

* Update item_barcode_childtable_migrate.py
2018-02-23 16:19:41 +05:30

27 lines
654 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():
items_barcode = frappe.get_list('Item', ['name', 'barcode'], { 'barcode': ('!=', '') })
frappe.reload_doc("stock", "doctype", "item")
frappe.reload_doc("stock", "doctype", "item_barcode")
for item in items_barcode:
barcode = item.barcode.strip()
if barcode and '<' not in barcode:
frappe.get_doc({
'idx': 0,
'doctype': 'Item Barcode',
'barcode': barcode,
'parenttype': 'Item',
'parent': item.name,
'parentfield': 'barcodes'
}).insert()