Hi Forum,
How to create Sales order from Purchase order and vise-versa? Kindly advise if its possible in standard ERPNext or customization required. Thanks!
1 Like
Hi @Amol_Anturkar,
That for, Please apply the client script in Purchase Order.
Check the syntax.
frappe.ui.form.on('Purchase Order', {
refresh: function(frm) {
frm.add_custom_button(__('Sales Order'), function() {
var sales_order = frappe.model.get_new_doc('Sales Order');
sales_order.naming_series = "SAL-ORD-.YYYY.-";
sales_order.transaction_date = frappe.datetime.get_today();
sales_order.delivery_date = frappe.datetime.get_today();
sales_order.company = frm.doc.company;
sales_order.customer = 'Customer 1';
sales_order.order_type = "Sales";
sales_order.selling_price_list = 'Standard Selling';
sales_order.currency = frm.doc.currency;
sales_order.items = frm.doc.items.map(function(item) {
return {
'item_code': item.item_code,
'item_name': item.item_name,
'rate': item.rate,
'qty': item.qty,
// 'warehouse': item.warehouse // Set the warehouse field if required
};
});
frappe.call({
method: 'frappe.client.insert',
args: {
doc: sales_order
},
callback: function(response) {
if (response.message) {
frappe.msgprint("Sales Order created: " + response.message.name);
frappe.set_route('Form', 'Sales Order', response.message.name);
}
}
});
}, __('Create'));
}
});
Please set your field and match with sales order item according to purchase order item.
I hope this helps.
Thank You!
2 Likes
Many Thanks Nihantra!
It seems, need enhancement in standard ERPNext. I am not too technical, I will get/find developer to try and let you know.
With Best Regards,
Amol
1 Like