From cc0222a28a9a5d48f408937335507c7b9968cc7d Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 16 Feb 2019 17:53:23 +0530 Subject: [PATCH 1/5] Remove unwanted barcode field from item --- erpnext/stock/doctype/item/item.json | 90 ++++++++++++++++++---------- 1 file changed, 58 insertions(+), 32 deletions(-) diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json index 81997edfb4..58c907793a 100644 --- a/erpnext/stock/doctype/item/item.json +++ b/erpnext/stock/doctype/item/item.json @@ -38,6 +38,7 @@ "oldfieldtype": "Section Break", "options": "fa fa-flag", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -70,6 +71,7 @@ "no_copy": 0, "options": "STO-ITEM-.YYYY.-", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -104,6 +106,7 @@ "oldfieldname": "item_code", "oldfieldtype": "Data", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -172,6 +175,7 @@ "oldfieldname": "item_name", "oldfieldtype": "Data", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -183,37 +187,6 @@ "translatable": 0, "unique": 0 }, - { - "allow_bulk_edit": 0, - "allow_in_quick_entry": 0, - "allow_on_submit": 0, - "bold": 0, - "collapsible": 0, - "columns": 0, - "fieldname": "barcode", - "fieldtype": "Data", - "hidden": 0, - "ignore_user_permissions": 0, - "ignore_xss_filter": 0, - "in_filter": 0, - "in_global_search": 0, - "in_list_view": 0, - "in_standard_filter": 0, - "label": "Barcode", - "length": 0, - "no_copy": 1, - "permlevel": 0, - "print_hide": 0, - "print_hide_if_no_value": 0, - "read_only": 0, - "remember_last_selected_value": 0, - "report_hide": 0, - "reqd": 0, - "search_index": 0, - "set_only_once": 0, - "translatable": 0, - "unique": 0 - }, { "allow_bulk_edit": 0, "allow_in_quick_entry": 0, @@ -238,6 +211,7 @@ "oldfieldtype": "Link", "options": "Item Group", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -305,6 +279,7 @@ "oldfieldtype": "Link", "options": "UOM", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -335,6 +310,7 @@ "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -435,6 +411,7 @@ "oldfieldtype": "Select", "options": "", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -701,6 +678,7 @@ "oldfieldname": "tolerance", "oldfieldtype": "Currency", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -800,6 +778,7 @@ "oldfieldtype": "Link", "options": "Brand", "permlevel": 0, + "precision": "", "print_hide": 1, "print_hide_if_no_value": 0, "read_only": 0, @@ -833,6 +812,7 @@ "oldfieldname": "description", "oldfieldtype": "Text", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -933,6 +913,7 @@ "oldfieldtype": "Section Break", "options": "fa fa-truck", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1000,6 +981,7 @@ "oldfieldname": "end_of_life", "oldfieldtype": "Date", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1067,6 +1049,7 @@ "no_copy": 0, "options": "\nFIFO\nMoving Average", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1099,6 +1082,7 @@ "no_copy": 0, "oldfieldtype": "Column Break", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1134,6 +1118,7 @@ "oldfieldname": "warranty_period", "oldfieldtype": "Data", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1167,6 +1152,7 @@ "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1200,6 +1186,7 @@ "no_copy": 0, "options": "UOM", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1234,6 +1221,7 @@ "no_copy": 0, "options": "fa fa-rss", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1268,6 +1256,7 @@ "no_copy": 0, "options": "Item Reorder", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1337,6 +1326,7 @@ "oldfieldtype": "Table", "options": "UOM Conversion Detail", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1407,6 +1397,7 @@ "oldfieldtype": "Select", "options": "", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1643,6 +1634,7 @@ "oldfieldtype": "Select", "options": "", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1676,6 +1668,7 @@ "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -1913,6 +1906,7 @@ "oldfieldtype": "Section Break", "options": "fa fa-shopping-cart", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -2015,6 +2009,7 @@ "oldfieldname": "min_order_qty", "oldfieldtype": "Currency", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -2114,6 +2109,7 @@ "oldfieldname": "lead_time_days", "oldfieldtype": "Int", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -2148,6 +2144,7 @@ "oldfieldname": "last_purchase_rate", "oldfieldtype": "Currency", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, @@ -2246,6 +2243,7 @@ "no_copy": 0, "options": "Manufacturer", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -2278,6 +2276,7 @@ "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -2311,6 +2310,7 @@ "no_copy": 0, "oldfieldtype": "Column Break", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -2345,6 +2345,7 @@ "no_copy": 0, "options": "Item Supplier", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -2507,6 +2508,7 @@ "oldfieldtype": "Section Break", "options": "fa fa-tag", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -2606,6 +2608,7 @@ "no_copy": 0, "oldfieldtype": "Column Break", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -2641,6 +2644,7 @@ "oldfieldname": "max_discount", "oldfieldtype": "Currency", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3031,6 +3035,7 @@ "no_copy": 0, "options": "Item Customer Detail", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3064,6 +3069,7 @@ "oldfieldtype": "Section Break", "options": "fa fa-money", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3099,6 +3105,7 @@ "oldfieldtype": "Table", "options": "Item Tax", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3132,6 +3139,7 @@ "oldfieldtype": "Section Break", "options": "fa fa-search", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3167,6 +3175,7 @@ "oldfieldtype": "Select", "options": "", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3267,6 +3276,7 @@ "oldfieldtype": "Section Break", "options": "fa fa-cogs", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3302,6 +3312,7 @@ "oldfieldtype": "Link", "options": "BOM", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 1, @@ -3338,6 +3349,7 @@ "oldfieldtype": "Select", "options": "", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3400,6 +3412,7 @@ "length": 0, "no_copy": 1, "permlevel": 0, + "precision": "", "print_hide": 1, "print_hide_if_no_value": 0, "read_only": 0, @@ -3432,6 +3445,7 @@ "no_copy": 0, "options": "fa fa-globe", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3464,6 +3478,7 @@ "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3563,6 +3578,7 @@ "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3597,6 +3613,7 @@ "no_copy": 0, "options": "Website Slideshow", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3631,6 +3648,7 @@ "no_copy": 0, "options": "", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3693,6 +3711,7 @@ "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3727,6 +3746,7 @@ "no_copy": 0, "options": "Warehouse", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3761,6 +3781,7 @@ "no_copy": 0, "options": "Website Item Group", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3794,6 +3815,7 @@ "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3826,6 +3848,7 @@ "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3859,6 +3882,7 @@ "no_copy": 0, "options": "Item Website Specification", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -3891,6 +3915,7 @@ "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -4114,10 +4139,11 @@ "issingle": 0, "istable": 0, "max_attachments": 1, - "modified": "2019-01-07 16:52:05.096907", + "modified": "2019-02-16 17:43:56.039611", "modified_by": "Administrator", "module": "Stock", "name": "Item", + "name_case": "", "owner": "Administrator", "permissions": [ { From 8cbe824c5b196d776e23eca9a4f85a593a955e72 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 16 Feb 2019 17:54:15 +0530 Subject: [PATCH 2/5] Rerun item_barcode_chidtable_migrate patch --- erpnext/patches.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index b8e2e358b1..b3ccda666b 100755 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -488,7 +488,7 @@ erpnext.patches.v10_0.update_assessment_plan erpnext.patches.v10_0.update_assessment_result erpnext.patches.v10_0.set_default_payment_terms_based_on_company erpnext.patches.v10_0.update_sales_order_link_to_purchase_order -erpnext.patches.v10_0.item_barcode_childtable_migrate +erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019 erpnext.patches.v10_0.rename_price_to_rate_in_pricing_rule erpnext.patches.v10_0.set_currency_in_pricing_rule erpnext.patches.v10_0.set_b2c_limit From 1399fbe986f6a0a10a5721571c32851766ef542f Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 16 Feb 2019 21:02:34 +0530 Subject: [PATCH 3/5] Move patch --- erpnext/patches.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/patches.txt b/erpnext/patches.txt index b3ccda666b..2199491a71 100755 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -488,7 +488,6 @@ erpnext.patches.v10_0.update_assessment_plan erpnext.patches.v10_0.update_assessment_result erpnext.patches.v10_0.set_default_payment_terms_based_on_company erpnext.patches.v10_0.update_sales_order_link_to_purchase_order -erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019 erpnext.patches.v10_0.rename_price_to_rate_in_pricing_rule erpnext.patches.v10_0.set_currency_in_pricing_rule erpnext.patches.v10_0.set_b2c_limit @@ -586,3 +585,4 @@ erpnext.patches.v11_0.renamed_from_to_fields_in_project erpnext.patches.v11_0.add_permissions_in_gst_settings erpnext.patches.v11_1.setup_guardian_role execute:frappe.delete_doc('DocType', 'Notification Control') +erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019 \ No newline at end of file From 3a2f342ac180f53456b2def5bb809cd00047ef6d Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sat, 16 Feb 2019 21:09:24 +0530 Subject: [PATCH 4/5] Ignore duplicate entry --- .../v10_0/item_barcode_childtable_migrate.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/erpnext/patches/v10_0/item_barcode_childtable_migrate.py b/erpnext/patches/v10_0/item_barcode_childtable_migrate.py index c939dd5d33..a2e25795eb 100644 --- a/erpnext/patches/v10_0/item_barcode_childtable_migrate.py +++ b/erpnext/patches/v10_0/item_barcode_childtable_migrate.py @@ -16,11 +16,14 @@ def execute(): 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() + try: + frappe.get_doc({ + 'idx': 0, + 'doctype': 'Item Barcode', + 'barcode': barcode, + 'parenttype': 'Item', + 'parent': item.name, + 'parentfield': 'barcodes' + }).insert() + except frappe.DuplicateEntryError: + continue From 053d6a2ca13b1f36a02fa3223092a10af35f6579 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Sun, 17 Feb 2019 11:24:51 +0530 Subject: [PATCH 5/5] Move reload doc before get query --- erpnext/patches/v10_0/item_barcode_childtable_migrate.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/patches/v10_0/item_barcode_childtable_migrate.py b/erpnext/patches/v10_0/item_barcode_childtable_migrate.py index a2e25795eb..bc6005677d 100644 --- a/erpnext/patches/v10_0/item_barcode_childtable_migrate.py +++ b/erpnext/patches/v10_0/item_barcode_childtable_migrate.py @@ -7,11 +7,13 @@ import frappe def execute(): - items_barcode = frappe.get_all('Item', ['name', 'barcode'], { 'barcode': ('!=', '') }) - - frappe.reload_doc("stock", "doctype", "item") frappe.reload_doc("stock", "doctype", "item_barcode") + items_barcode = frappe.get_all('Item', ['name', 'barcode'], { 'barcode': ('!=', '') }) + frappe.reload_doc("stock", "doctype", "item") + + + for item in items_barcode: barcode = item.barcode.strip()