Hello Community,
I am trying to Submit a Stock Entry “Material Transfer” on Saving of Sales Order.
Warehouses : “Parent WH” and “Child WH”
Item : Item001
Actual Qty : 10Nos. in Parent WH
Actual Qty : 0 Nos in Child WH
Now When “Sales Order” is saved for Item001 with Qty. 1,
A Stock Entry Should be Submitted to transfer material from Parent WH to Child WH for Qty 1.
When I am “testing” below Server Script with default data on Doctype Event “After Save”, Its submitting Stock Entry two times first is on After Save and another on Submit.
stock_entry = frappe.get_doc({
"doctype": "Stock Entry",
"stock_entry_type": "Material Transfer"
})
stock_entry.append('items', {
"s_warehouse": "Parent WH - MC",
"t_warehouse": "Child WH - MC",
"item_code": "Item001",
"qty": 1,
"uom": "Nos"
})
stock_entry.insert().submit()
What I am doing wrong?