minor random trigger changes and exception handling
diff --git a/erpnext/demo/user/purchase.py b/erpnext/demo/user/purchase.py
index 69dee00..781c304 100644
--- a/erpnext/demo/user/purchase.py
+++ b/erpnext/demo/user/purchase.py
@@ -162,7 +162,7 @@
"item_code": items.get("item_code"),
"rm_item_code": supplied_items.get("rm_item_code"),
"item_name": supplied_items.get("rm_item_code"),
- "qty": supplied_items.get("required_qty"),
+ "qty": supplied_items.get("required_qty") + random.randint(3,10),
"amount": supplied_items.get("amount"),
"warehouse": supplied_items.get("reserve_warehouse"),
"rate": supplied_items.get("rate"),
diff --git a/erpnext/demo/user/sales.py b/erpnext/demo/user/sales.py
index 304576a..fbeeff4 100644
--- a/erpnext/demo/user/sales.py
+++ b/erpnext/demo/user/sales.py
@@ -34,21 +34,24 @@
opportunity.declare_enquiry_lost('Did not ask')
for i in range(random.randint(1,3)):
- if random.random() < 0.3:
+ if random.random() < 0.6:
make_sales_order()
if random.random() < 0.5:
#make payment request against Sales Order
sales_order_name = get_random("Sales Order", filters={"docstatus": 1})
- if sales_order_name:
- so = frappe.get_doc("Sales Order", sales_order_name)
- if flt(so.per_billed) != 100:
- payment_request = make_payment_request(dt="Sales Order", dn=so.name, recipient_id=so.contact_email,
- submit_doc=True, mute_email=True, use_dummy_message=True)
+ try:
+ if sales_order_name:
+ so = frappe.get_doc("Sales Order", sales_order_name)
+ if flt(so.per_billed) != 100:
+ payment_request = make_payment_request(dt="Sales Order", dn=so.name, recipient_id=so.contact_email,
+ submit_doc=True, mute_email=True, use_dummy_message=True)
- payment_entry = frappe.get_doc(make_payment_entry(payment_request.name))
- payment_entry.posting_date = frappe.flags.current_date
- payment_entry.submit()
+ payment_entry = frappe.get_doc(make_payment_entry(payment_request.name))
+ payment_entry.posting_date = frappe.flags.current_date
+ payment_entry.submit()
+ except Exception:
+ pass
def make_opportunity():
b = frappe.get_doc({
diff --git a/erpnext/demo/user/stock.py b/erpnext/demo/user/stock.py
index 50257dc..6036a26 100644
--- a/erpnext/demo/user/stock.py
+++ b/erpnext/demo/user/stock.py
@@ -56,8 +56,9 @@
if not d.expense_account:
d.expense_account = ("Cost of Goods Sold - {0}".format(
frappe.get_cached_value('Company', dn.company, 'abbr')))
- dn.insert()
+
try:
+ dn.insert()
dn.submit()
frappe.db.commit()
except (NegativeStockError, SerialNoRequiredError, SerialNoQtyError, UnableToSelectBatchError):