How to manually triggers SO on submit events
Jump to navigation
Jump to search
Abstract[edit]
Sometimes, IDS fails while submitting SO documents despite the `Delivery Order` successfully sent and created on WMS and fails to receive a response from WMS due to the user behavior [spam clicking submit button while the request is already sent] and problematic/unstable internet connection which cause a more serious issue. We must do a post-mortem evaluation to fix the issue.
Who is this article intended for?[edit]
You are the one who:
- Understand basic bash command
- Understand basic Python language
- Have access to IDS Server
- Have registered ssh key on IDS Server
How to do it ?[edit]
On this page, you'll learn how to manually trigger SO on submit events as a temporary.
Steps[edit]
- Have the SO Number collection
- Connect to IDS Server via SSH
- Change the working directory to IDS root folder
- Enter Bench console
- Execute Python code
- Commit changes
1. Ensure you already have SO number collection[edit]
2. Connect to IDS server via SSH[edit]
ssh {username}@{host} -p {port} -i /path/to/your-identity-file
3. Change the working directory[edit]
cd /path/to/ids-root-folder
4. Enter Bench console[edit]
bench console
Now, you're inside IDS environtment.
5. Execute Python code[edit]
For example, you want to manually trigger SO On Submit events of SO SO123, SO1234.
# Make a Python list of SO document name
so_list = ["SO123", "SO1234"]
# Now create a python loop and get the document using the built-in frappe feature `frappe.get_doc("{DocType Name}", "{Document Name}")`
# Begin SQL Transaction
frappe.db.begin()
try:
for doc_name in so_list:
doc = frappe.get_doc("Sales Order", doc_name)
# Skip if the document has not been submitted yet
if doc.docstatus == 0:
continue
# Update reserved items quantity
doc.update_reserved_qty()
# Update CPO Items ordered quantity
doc.update_cpo_item_ordered_qty()
# Update CPO status
doc.update_cpo_status()
# Commit SQL Transaction when no error ocurred
frappe.db.commit()
except:
# Rollback SQL transaction on error
frappe.db.rollback()