item data fix for default supplier, exception handling for purchase order

This commit is contained in:
Zlash65 2018-10-01 12:55:07 +05:30
parent d080a17961
commit 8b1133cb24
2 changed files with 77 additions and 73 deletions

View File

@ -1,9 +1,9 @@
[ [
{ {
"default_supplier": "Asiatic Solutions", "item_defaults": [{
"item_defaults": [{ "default_supplier": "Asiatic Solutions",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "For Upper Bearing", "description": "For Upper Bearing",
"image": "/assets/erpnext_demo/images/disc.png", "image": "/assets/erpnext_demo/images/disc.png",
"item_code": "Disc Collars", "item_code": "Disc Collars",
@ -11,9 +11,9 @@
"item_name": "Disc Collars" "item_name": "Disc Collars"
}, },
{ {
"default_supplier": "Nan Duskin", "item_defaults": [{
"item_defaults": [{ "default_supplier": "Nan Duskin",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "CAST IRON, MCMASTER PART NO. 3710T13", "description": "CAST IRON, MCMASTER PART NO. 3710T13",
"image": "/assets/erpnext_demo/images/bearing.jpg", "image": "/assets/erpnext_demo/images/bearing.jpg",
@ -22,9 +22,9 @@
"item_name": "Bearing Block" "item_name": "Bearing Block"
}, },
{ {
"default_supplier": null, "item_defaults": [{
"item_defaults": [{ "default_supplier": null,
"default_warehouse": "Finished Goods" "default_warehouse": "Finished Goods"
}], }],
"description": "Wind Mill C Series for Commercial Use 18ft", "description": "Wind Mill C Series for Commercial Use 18ft",
"image": "/assets/erpnext_demo/images/wind-turbine-2.png", "image": "/assets/erpnext_demo/images/wind-turbine-2.png",
@ -33,9 +33,9 @@
"item_name": "Wind MIll C Series" "item_name": "Wind MIll C Series"
}, },
{ {
"default_supplier": null, "item_defaults": [{
"item_defaults": [{ "default_supplier": null,
"default_warehouse": "Finished Goods" "default_warehouse": "Finished Goods"
}], }],
"description": "Wind Mill A Series for Home Use 9ft", "description": "Wind Mill A Series for Home Use 9ft",
"image": "/assets/erpnext_demo/images/wind-turbine.png", "image": "/assets/erpnext_demo/images/wind-turbine.png",
@ -44,9 +44,9 @@
"item_name": "Wind Mill A Series" "item_name": "Wind Mill A Series"
}, },
{ {
"default_supplier": null, "item_defaults": [{
"item_defaults": [{ "default_supplier": null,
"default_warehouse": "Finished Goods" "default_warehouse": "Finished Goods"
}], }],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->", "description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg", "image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
@ -60,9 +60,9 @@
] ]
}, },
{ {
"default_supplier": "HomeBase", "item_defaults": [{
"item_defaults": [{ "default_supplier": "HomeBase",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "1.5 in. Diameter x 36 in. Mild Steel Tubing", "description": "1.5 in. Diameter x 36 in. Mild Steel Tubing",
"image": null, "image": null,
@ -71,9 +71,9 @@
"item_name": "Bearing Pipe" "item_name": "Bearing Pipe"
}, },
{ {
"default_supplier": "New World Realty", "item_defaults": [{
"item_defaults": [{ "default_supplier": "New World Realty",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet", "description": "1/32 in. x 24 in. x 47 in. HDPE Opaque Sheet",
"image": null, "image": null,
@ -82,9 +82,9 @@
"item_name": "Wing Sheet" "item_name": "Wing Sheet"
}, },
{ {
"default_supplier": "Eagle Hardware", "item_defaults": [{
"item_defaults": [{ "default_supplier": "Eagle Hardware",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate", "description": "3/16 in. x 6 in. x 6 in. Low Carbon Steel Plate",
"image": null, "image": null,
@ -93,9 +93,9 @@
"item_name": "Upper Bearing Plate" "item_name": "Upper Bearing Plate"
}, },
{ {
"default_supplier": "Asiatic Solutions", "item_defaults": [{
"item_defaults": [{ "default_supplier": "Asiatic Solutions",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "Bearing Assembly", "description": "Bearing Assembly",
"image": null, "image": null,
@ -104,9 +104,9 @@
"item_name": "Bearing Assembly" "item_name": "Bearing Assembly"
}, },
{ {
"default_supplier": "HomeBase", "item_defaults": [{
"item_defaults": [{ "default_supplier": "HomeBase",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "3/4 in. x 2 ft. x 4 ft. Pine Plywood", "description": "3/4 in. x 2 ft. x 4 ft. Pine Plywood",
"image": null, "image": null,
@ -116,9 +116,9 @@
"is_sub_contracted_item": 1 "is_sub_contracted_item": 1
}, },
{ {
"default_supplier": "Scott Ties", "item_defaults": [{
"item_defaults": [{ "default_supplier": "Scott Ties",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "N/A", "description": "N/A",
"image": null, "image": null,
@ -127,9 +127,9 @@
"item_name": "Stand" "item_name": "Stand"
}, },
{ {
"default_supplier": "Eagle Hardware", "item_defaults": [{
"item_defaults": [{ "default_supplier": "Eagle Hardware",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar", "description": "1 in. x 3 in. x 1 ft. Multipurpose Al Alloy Bar",
"image": null, "image": null,
@ -138,9 +138,9 @@
"item_name": "Bearing Collar" "item_name": "Bearing Collar"
}, },
{ {
"default_supplier": "Eagle Hardware", "item_defaults": [{
"item_defaults": [{ "default_supplier": "Eagle Hardware",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "1/4 in. x 6 in. x 6 in. Mild Steel Plate", "description": "1/4 in. x 6 in. x 6 in. Mild Steel Plate",
"image": null, "image": null,
@ -149,9 +149,9 @@
"item_name": "Base Bearing Plate" "item_name": "Base Bearing Plate"
}, },
{ {
"default_supplier": "HomeBase", "item_defaults": [{
"item_defaults": [{ "default_supplier": "HomeBase",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing", "description": "15/32 in. x 4 ft. x 8 ft. 3-Ply Rtd Sheathing",
"image": null, "image": null,
@ -160,9 +160,9 @@
"item_name": "External Disc" "item_name": "External Disc"
}, },
{ {
"default_supplier": "Eagle Hardware", "item_defaults": [{
"item_defaults": [{ "default_supplier": "Eagle Hardware",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "1.25 in. Diameter x 6 ft. Mild Steel Tubing", "description": "1.25 in. Diameter x 6 ft. Mild Steel Tubing",
"image": null, "image": null,
@ -171,9 +171,9 @@
"item_name": "Shaft" "item_name": "Shaft"
}, },
{ {
"default_supplier": "Ks Merchandise", "item_defaults": [{
"item_defaults": [{ "default_supplier": "Ks Merchandise",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "1/2 in. x 2 ft. x 4 ft. Pine Plywood", "description": "1/2 in. x 2 ft. x 4 ft. Pine Plywood",
"image": null, "image": null,
@ -182,9 +182,9 @@
"item_name": "Blade Rib" "item_name": "Blade Rib"
}, },
{ {
"default_supplier": "HomeBase", "item_defaults": [{
"item_defaults": [{ "default_supplier": "HomeBase",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "For Bearing Collar", "description": "For Bearing Collar",
"image": null, "image": null,
@ -193,9 +193,9 @@
"item_name": "Internal Disc" "item_name": "Internal Disc"
}, },
{ {
"default_supplier": null, "item_defaults": [{
"item_defaults": [{ "default_supplier": null,
"default_warehouse": "Finished Goods" "default_warehouse": "Finished Goods"
}], }],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Small</p>", "description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Small</p>",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg", "image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
@ -212,9 +212,9 @@
] ]
}, },
{ {
"default_supplier": null, "item_defaults": [{
"item_defaults": [{ "default_supplier": null,
"default_warehouse": "Finished Goods" "default_warehouse": "Finished Goods"
}], }],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Medium</p>", "description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Medium</p>",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg", "image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
@ -231,9 +231,9 @@
] ]
}, },
{ {
"default_supplier": null, "item_defaults": [{
"item_defaults": [{ "default_supplier": null,
"default_warehouse": "Finished Goods" "default_warehouse": "Finished Goods"
}], }],
"description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Large</p>", "description": "Small Wind Turbine for Home Use\n\n\n<!-- html -->\n<p>Size: Large</p>",
"image": "/assets/erpnext_demo/images/wind-turbine-1.jpg", "image": "/assets/erpnext_demo/images/wind-turbine-1.jpg",
@ -257,9 +257,9 @@
"item_name": "Wind Mill A Series with Spare Bearing" "item_name": "Wind Mill A Series with Spare Bearing"
}, },
{ {
"default_supplier": "HomeBase", "item_defaults": [{
"item_defaults": [{ "default_supplier": "HomeBase",
"default_warehouse": "Stores" "default_warehouse": "Stores"
}], }],
"description": "3/4 in. x 2 ft. x 4 ft. Pine Plywood", "description": "3/4 in. x 2 ft. x 4 ft. Pine Plywood",
"image": null, "image": null,

View File

@ -51,7 +51,7 @@ def work():
# get supplier details # get supplier details
supplier = get_random("Supplier") 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") party_account_currency = get_party_account_currency("Supplier", supplier, "Wind Power LLC")
if company_currency == party_account_currency: if company_currency == party_account_currency:
exchange_rate = 1 exchange_rate = 1
@ -80,14 +80,18 @@ def work():
report = "Requested Items To Be Ordered" report = "Requested Items To Be Ordered"
for row in query_report.run(report)["result"][:how_many("Purchase Order")]: for row in query_report.run(report)["result"][:how_many("Purchase Order")]:
if row[0] != "'Total'": if row[0] != "'Total'":
po = frappe.get_doc(make_purchase_order(row[0])) try:
po.supplier = supplier po = frappe.get_doc(make_purchase_order(row[0]))
po.currency = party_account_currency or company_currency po.supplier = supplier
po.conversion_rate = exchange_rate po.currency = party_account_currency or company_currency
po.transaction_date = frappe.flags.current_date po.conversion_rate = exchange_rate
po.insert() po.transaction_date = frappe.flags.current_date
po.submit() po.insert()
frappe.db.commit() po.submit()
except Exception:
pass
else:
frappe.db.commit()
if random.random() < 0.5: if random.random() < 0.5:
make_subcontract() make_subcontract()