From 8b1133cb2489525ba48d13393b52a3ba964487ce Mon Sep 17 00:00:00 2001 From: Zlash65 Date: Mon, 1 Oct 2018 12:55:07 +0530 Subject: [PATCH] item data fix for default supplier, exception handling for purchase order --- erpnext/demo/data/item.json | 128 +++++++++++++++++----------------- erpnext/demo/user/purchase.py | 22 +++--- 2 files changed, 77 insertions(+), 73 deletions(-) diff --git a/erpnext/demo/data/item.json b/erpnext/demo/data/item.json index 908de15d0b..e77d8cb17d 100644 --- a/erpnext/demo/data/item.json +++ b/erpnext/demo/data/item.json @@ -1,9 +1,9 @@ [ { - "default_supplier": "Asiatic Solutions", - "item_defaults": [{ - "default_warehouse": "Stores" - }], + "item_defaults": [{ + "default_supplier": "Asiatic Solutions", + "default_warehouse": "Stores" + }], "description": "For Upper Bearing", "image": "/assets/erpnext_demo/images/disc.png", "item_code": "Disc Collars", @@ -11,9 +11,9 @@ "item_name": "Disc Collars" }, { - "default_supplier": "Nan Duskin", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "Nan Duskin", + "default_warehouse": "Stores" }], "description": "CAST IRON, MCMASTER PART NO. 3710T13", "image": "/assets/erpnext_demo/images/bearing.jpg", @@ -22,9 +22,9 @@ "item_name": "Bearing Block" }, { - "default_supplier": null, - "item_defaults": [{ - "default_warehouse": "Finished Goods" + "item_defaults": [{ + "default_supplier": null, + "default_warehouse": "Finished Goods" }], "description": "Wind Mill C Series for Commercial Use 18ft", "image": "/assets/erpnext_demo/images/wind-turbine-2.png", @@ -33,9 +33,9 @@ "item_name": "Wind MIll C Series" }, { - "default_supplier": null, - "item_defaults": [{ - "default_warehouse": "Finished Goods" + "item_defaults": [{ + "default_supplier": null, + "default_warehouse": "Finished Goods" }], "description": "Wind Mill A Series for Home Use 9ft", "image": "/assets/erpnext_demo/images/wind-turbine.png", @@ -44,9 +44,9 @@ "item_name": "Wind Mill A Series" }, { - "default_supplier": null, - "item_defaults": [{ - "default_warehouse": "Finished Goods" + "item_defaults": [{ + "default_supplier": null, + "default_warehouse": "Finished Goods" }], "description": "Small Wind Turbine for Home Use\n\n\n", "image": "/assets/erpnext_demo/images/wind-turbine-1.jpg", @@ -60,9 +60,9 @@ ] }, { - "default_supplier": "HomeBase", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "HomeBase", + "default_warehouse": "Stores" }], "description": "1.5 in. Diameter x 36 in. Mild Steel Tubing", "image": null, @@ -71,9 +71,9 @@ "item_name": "Bearing Pipe" }, { - "default_supplier": "New World Realty", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "New World Realty", + "default_warehouse": "Stores" }], "description": "1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet", "image": null, @@ -82,9 +82,9 @@ "item_name": "Wing Sheet" }, { - "default_supplier": "Eagle Hardware", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "Eagle Hardware", + "default_warehouse": "Stores" }], "description": "3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate", "image": null, @@ -93,9 +93,9 @@ "item_name": "Upper Bearing Plate" }, { - "default_supplier": "Asiatic Solutions", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "Asiatic Solutions", + "default_warehouse": "Stores" }], "description": "Bearing Assembly", "image": null, @@ -104,9 +104,9 @@ "item_name": "Bearing Assembly" }, { - "default_supplier": "HomeBase", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "HomeBase", + "default_warehouse": "Stores" }], "description": "3/4 in. x 2 ft. x 4 ft. Pine Plywood", "image": null, @@ -116,9 +116,9 @@ "is_sub_contracted_item": 1 }, { - "default_supplier": "Scott Ties", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "Scott Ties", + "default_warehouse": "Stores" }], "description": "N/A", "image": null, @@ -127,9 +127,9 @@ "item_name": "Stand" }, { - "default_supplier": "Eagle Hardware", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "Eagle Hardware", + "default_warehouse": "Stores" }], "description": "1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar", "image": null, @@ -138,9 +138,9 @@ "item_name": "Bearing Collar" }, { - "default_supplier": "Eagle Hardware", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "Eagle Hardware", + "default_warehouse": "Stores" }], "description": "1/4 in. x 6 in. x 6 in. Mild Steel Plate", "image": null, @@ -149,9 +149,9 @@ "item_name": "Base Bearing Plate" }, { - "default_supplier": "HomeBase", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "HomeBase", + "default_warehouse": "Stores" }], "description": "15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing", "image": null, @@ -160,9 +160,9 @@ "item_name": "External Disc" }, { - "default_supplier": "Eagle Hardware", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "Eagle Hardware", + "default_warehouse": "Stores" }], "description": "1.25 in. Diameter x 6 ft. Mild Steel Tubing", "image": null, @@ -171,9 +171,9 @@ "item_name": "Shaft" }, { - "default_supplier": "Ks Merchandise", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "Ks Merchandise", + "default_warehouse": "Stores" }], "description": "1/2 in. x 2 ft. x 4 ft. Pine Plywood", "image": null, @@ -182,9 +182,9 @@ "item_name": "Blade Rib" }, { - "default_supplier": "HomeBase", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "HomeBase", + "default_warehouse": "Stores" }], "description": "For Bearing Collar", "image": null, @@ -193,9 +193,9 @@ "item_name": "Internal Disc" }, { - "default_supplier": null, - "item_defaults": [{ - "default_warehouse": "Finished Goods" + "item_defaults": [{ + "default_supplier": null, + "default_warehouse": "Finished Goods" }], "description": "Small Wind Turbine for Home Use\n\n\n\n

Size: Small

", "image": "/assets/erpnext_demo/images/wind-turbine-1.jpg", @@ -212,9 +212,9 @@ ] }, { - "default_supplier": null, - "item_defaults": [{ - "default_warehouse": "Finished Goods" + "item_defaults": [{ + "default_supplier": null, + "default_warehouse": "Finished Goods" }], "description": "Small Wind Turbine for Home Use\n\n\n\n

Size: Medium

", "image": "/assets/erpnext_demo/images/wind-turbine-1.jpg", @@ -231,9 +231,9 @@ ] }, { - "default_supplier": null, - "item_defaults": [{ - "default_warehouse": "Finished Goods" + "item_defaults": [{ + "default_supplier": null, + "default_warehouse": "Finished Goods" }], "description": "Small Wind Turbine for Home Use\n\n\n\n

Size: Large

", "image": "/assets/erpnext_demo/images/wind-turbine-1.jpg", @@ -257,9 +257,9 @@ "item_name": "Wind Mill A Series with Spare Bearing" }, { - "default_supplier": "HomeBase", - "item_defaults": [{ - "default_warehouse": "Stores" + "item_defaults": [{ + "default_supplier": "HomeBase", + "default_warehouse": "Stores" }], "description": "3/4 in. x 2 ft. x 4 ft. Pine Plywood", "image": null, diff --git a/erpnext/demo/user/purchase.py b/erpnext/demo/user/purchase.py index 781c304271..822a4fcd2e 100644 --- a/erpnext/demo/user/purchase.py +++ b/erpnext/demo/user/purchase.py @@ -51,7 +51,7 @@ def work(): # get supplier details supplier = get_random("Supplier") - company_currency = frappe.get_cached_value('Company', "Wind Power LLC", "default_currency") + company_currency = frappe.get_cached_value('Company', "Wind Power LLC", "default_currency") party_account_currency = get_party_account_currency("Supplier", supplier, "Wind Power LLC") if company_currency == party_account_currency: exchange_rate = 1 @@ -80,14 +80,18 @@ def work(): report = "Requested Items To Be Ordered" for row in query_report.run(report)["result"][:how_many("Purchase Order")]: if row[0] != "'Total'": - po = frappe.get_doc(make_purchase_order(row[0])) - po.supplier = supplier - po.currency = party_account_currency or company_currency - po.conversion_rate = exchange_rate - po.transaction_date = frappe.flags.current_date - po.insert() - po.submit() - frappe.db.commit() + try: + po = frappe.get_doc(make_purchase_order(row[0])) + po.supplier = supplier + po.currency = party_account_currency or company_currency + po.conversion_rate = exchange_rate + po.transaction_date = frappe.flags.current_date + po.insert() + po.submit() + except Exception: + pass + else: + frappe.db.commit() if random.random() < 0.5: make_subcontract()