Try ERPNext Buy Support Partners Foundation

Link Delivery Date with Posting Date

Plz See the screenshot, no description need :slight_smile:

Plz help me to do this

Hello @aamunim,

frappe.ui.form.on('Sales Order', 'refresh', function(frm) {
	var days=3;
	var newDate=new Date(new Date (cur_frm.doc.transaction_date).getTime() + days*24*60*60*1000);
	cur_frm.set_value("delivery_date",newDate);
});
frappe.ui.form.on('Sales Order', 'transaction_date', function(frm) {
	var days=3;
	var newDate=new Date(new Date (cur_frm.doc.transaction_date).getTime() + days*24*60*60*1000);
	cur_frm.set_value("delivery_date",newDate);
});

Put this code snippet on refresh trigger and transation_date trigger .

2 Likes

i don’t understand where i put this code, can u tell more details plz?

In Sales Order Js file.

1 Like

Thank you So much it works perfectly

it works but no sales order will not saved after putting this script

what error you are getting?

no sales oder can be save after putting this script

Okay,It is because refresh function is always triggers whenever page is loaded or opened to solve this problem, just add if statement in refresh trigger

 frappe.ui.form.on('Sales Order', 'refresh', function(frm) {
if (cur_frm.doc.__islocal != undefined){
var days=3;
var newDate=new Date(new Date (cur_frm.doc.transaction_date).getTime() + days*24*60*60*1000);
cur_frm.set_value("delivery_date",newDate);
}
});

i can’t understand exactly where i put this code, can u tell me more details? if i put it on sales_order.js , erpnext server got brokern :frowning:

this is custom script for sales_order so u have put it into sales_order.js file only.