Hi team,
Whenever sales order is submitted , a stock transfer entry should be created in background automatically with reference to the sales order for all items. How to achieve this for all sales order items?
Hi team,
Whenever sales order is submitted , a stock transfer entry should be created in background automatically with reference to the sales order for all items. How to achieve this for all sales order items?
Write std hooks event
on_submit
doc_events = {
'Sales Order': {
'on_submit': '<app.custom_path.custom_method>'
}
}
def custom_method(doc,method=None):
#get new doc save and submit
You can create a custom script for that.
frappe.ui.form.on('Sale Order', 'on_submit', function(frm, cdt, cdn) {
const batch = frappe.model.get_new_doc('Batch');
batch.item = 'SAC';
batch.batch_id = 'Insert3';
frappe.db.insert(batch);
});
Thanks @khushal_t and @TurkerTunali
I have written one hook in my custom app and i have written one method in my custom doctype. Whenever sales order is submitted a stock entry type of “Material Transfer” will be created in background automatically. Now i am stuck on sales order items (i.e the sales order item contains qty, uom ,item code etc these attributes should get triggered in stock entry item table.
plz find the code
doc_events = {
“Sales Order”: {
“before_insert”: [“gerb.gerb.doctype.sales_order.sales_order.create_stock_entry”]
}
}
this is my sales order.py
from future import unicode_literals
import frappe
from frappe.model.document import Document
class SalesOrder(Document):
pass
def create_stock_entry(doc, handler=“”):
doc = frappe.new_doc(“Stock Entry”)
doc.update({ “purpose”: “Material Transfer” , “stock_entry_type”: “Material Transfer” , “from_warehouse”: “Reservation Warehouse - GS” , “to_warehouse”: “Finished Goods - GS” })
doc.insert()
, on creating the sales order automatically a stock entry is created , but i am unable to fetch the sales order item data into stock entry detail(i.e child table )
Hi @TurkerTunali and @khushal_t,
Here is the final solution for creating the doc and child items data
def create_stock_entry(doc, handler=""):
se = frappe.new_doc("Stock Entry")
se.update({ "purpose": "Material Transfer" , "stock_entry_type": "Material Transfer" , "from_warehouse": "Reservation Warehouse - G" , "to_warehouse": "Finished Goods - G" })
for se_item in doc.items:
se.append("items", { "item_code":se_item.item_code, "item_group": se_item.item_group, "item_name":se_item.item_name, "amount":se_item.amount, "qty": se_item.qty , "uom":se_item.uom, "conversion_factor": se_item.conversion_factor })
frappe.msgprint('Stock Entry is created please submit the stock entry')
se.insert()
Great.
You may also submit it by
se.docstatus=1
ya correct , right now i am keeping in draft only
its not right
its not working
Can you please post what went wrong what is not working so that we can correct or give alternative solution
Create Stock Transfer Entry Automatically on submit of Sales Order ? how i can do that