Can you please explain the steps you want to take. At this moment you have the Delivery Warehouse in Company master and Customer master.
What is the level of importance?
Do you want to fetch from Company - > Customer → Sales Order or Company - > Sales Order?
Thanks
Since i have multiple warehouse in just one company, my main purpose is to fetch Delivery Warehouse to Sales Order item level, so that user don’t need change it in every items in Sales Order.
frappe.ui.form.on("Sales Order","validate", function(){
for (var i =0; i < cur_frm.doc.items.length; i++){
cur_frm.doc.items[i].warehouse = cur_frm.doc.delivery_warehouse
}
cur_frm.refresh_field('items')
});
This script will copy the delivery_warehouse field into all rows when you click save in the sales order
Actually you do not need to put it in your company master at all, it is useless, because the default warehouse can be set in Stock Settings for that purpose.
hello,
I have near about same problem in which i want warehouse from user to sales order.
so that when that particular customer logs in warehouse will be fetched from the user section where i have created one custom field “warehouse” of link type into the sales order item "delivery warehouse " field which is also of link type as in 2nd screen shot
I have followed your all steps but is not working with following script i have added script in “Sales Order”
cur_frm.add_fetch(“user”, “warehouse”, “warehouse”);
frappe.ui.form.on("Sales Order Item","validate", function(){
for (var i =0; i < cur_frm.doc.items.length; i++){
cur_frm.doc.items[i].warehouse = cur_frm.doc.warehouse
}
cur_frm.refresh_field('items')
});
thank you @mrmo
I have applied the suggestion but not working there is error in script.
to be fetch from
custom field named “warehouse” in “user” doctype.
into
“warehouse”(not custom field) in items of sales order referenced from sales order item.
You have to create a custom field “warehouse” (read only) in Sales Order also, to fetch the field from user first.
copy my script below, because yours has wrong quotes.
@mrmo, you sound very familiar with Custom Scripts. I’ve been looking for ways for scripting the action of taking a list of Purchase Invoice Items and making a Product Bundle with them. Do you know what JS objects I need to get the Items and make a Product Bundle object? I literally can’t find any documentations what APIs are available to me in Custom Scripts and that’s been a very, very frustrating experience.
What happens is, that when you input the Purchase Invoice ID into that field it will fetch all items in the items child table and put them in your Product Bundle Child Table.
Your way is fine, but using your script as reference, I’m attempting to make a script to create new Product Bundle when I submit the Purchase Invoice because it’ll be an undue burden on my target users.
Besides that, my Googling informed be cur_frm has been deprecated, are you sure it will work? I’m on v11.
I must have missed that depreciation notice, thank you for the info. I will try to find a way to auto create product -bundle and will answer in the new post you created, which will be better.