I needed to have an auto populate today date in “Valid From” whenever item price is inputted or updated.
thank you so much
I needed to have an auto populate today date in “Valid From” whenever item price is inputted or updated.
thank you so much
Hi @xchicox ,
you can use this code to achieve the date update
frappe.ui.form.on('Item Price', {
validate: function(frm) {
if(!frm.doc.__islocal) {
frm.set_value('valid_from', frappe.datetime.now_date());
}
}
});
The system by default when the form is new will take the ‘today’ as the created date in valid_from. Also, you need to make sure that the valid _upto date is higher than the valid_from field to avoid errors.
Thanks. !
thank you so much, but is there a way that the “Valid From” will only change to todays date once their is an update in “Rate” field. This time the date change whenever i open the module
Thank you so much
frappe.ui.form.on(‘Item Price’, {
validate: function(frm) {
if(!frm.doc.__islocal) {
frm.set_value('valid_from', frappe.datetime.now_date());
}
}
});
frappe.ui.form.on(‘Item Price’, {
refresh: function(frm) {
frm.set_value(‘valid_upto’, frappe.datetime.add_months(frm.doc.valid_from, 6));
frm.save();
}
});
is this correct?
@xchicox use this :
frappe.ui.form.on('Item Price', {
price_list_rate: function(frm) {
frm.set_value('valid_from', frappe.datetime.now_date());
}
});
this code will be executed when rate is updated.
Thank you so so much,
frappe.ui.form.on(‘Item Price’, {
price_list_rate: function(frm) {
frm.set_value(‘valid_from’, frappe.datetime.now_date());
}
});
frappe.ui.form.on(‘Item Price’, {
price_list_rate: function(frm) {
frm.set_value(‘valid_upto’, frappe.datetime.now_date());
}
});
frappe.ui.form.on(‘Item Price’, {
refresh: function(frm) {
frm.set_value(‘valid_upto’, frappe.datetime.add_months(frm.doc.valid_from, 6));
frm.save();
}
});
this code will get the date today for valid from and valid upto then it will change valid upto date 6months
Hi @bahaou do you know the script if i want the below script only work in specific pricelist like ïn "Product Cost"only.
frappe.ui.form.on(‘Item Price’, {
refresh: function(frm) {
frm.set_value(‘valid_upto’, frappe.datetime.add_months(frm.doc.valid_from, 6));
frm.save();