Patch optimization (#13060)

* Patch fixes

* fix codacy

* Update item_barcode_childtable_migrate.py
This commit is contained in:
Faris Ansari
2018-02-23 16:19:41 +05:30
committed by Nabin Hait
parent 1a9388acbb
commit 97b212e348
2 changed files with 14 additions and 9 deletions

View File

@@ -7,16 +7,20 @@ import frappe
def execute(): def execute():
items_barcode = frappe.db.sql("""SELECT name, barcode FROM tabItem items_barcode = frappe.get_list('Item', ['name', 'barcode'], { 'barcode': ('!=', '') })
WHERE barcode IS NOT NULL and barcode != ''""", as_dict=1)
frappe.reload_doc("stock", "doctype", "item") frappe.reload_doc("stock", "doctype", "item")
frappe.reload_doc("stock", "doctype", "item_barcode") frappe.reload_doc("stock", "doctype", "item_barcode")
for item in items_barcode: for item in items_barcode:
doc = frappe.get_doc("Item", item.get("name")) barcode = item.barcode.strip()
if item.get("barcode"):
doc.append("barcodes", {"barcode": item.get("barcode")}) if barcode and '<' not in barcode:
doc.flags.ignore_validate = True frappe.get_doc({
doc.flags.ignore_mandatory = True 'idx': 0,
doc.save() 'doctype': 'Item Barcode',
'barcode': barcode,
'parenttype': 'Item',
'parent': item.name,
'parentfield': 'barcodes'
}).insert()

View File

@@ -12,6 +12,7 @@ def execute():
if not po_item: if not po_item:
return return
frappe.reload_doc("stock", "doctype", "bin")
frappe.reload_doc("buying", "doctype", "purchase_order_item_supplied") frappe.reload_doc("buying", "doctype", "purchase_order_item_supplied")
company_warehouse = frappe._dict(frappe.db.sql("""select company, min(name) from `tabWarehouse` company_warehouse = frappe._dict(frappe.db.sql("""select company, min(name) from `tabWarehouse`
where is_group = 0 group by company""")) where is_group = 0 group by company"""))