@Gitika_parashar There is a workaround to achieve this. As follows;
-
In Customer Doctype add a custom link field called warehouse and when adding a new customer choose the warehouse you want to link the customer with.
(Or if you want to fetch it together with territory then add the custom field in territory doctype and do the add_fetch in customer custom script.) -
In the Sales Order add add a custom link field called warehouse also, and make it read only.
-
Go to Custom Script and create a new script for Sales Order as follows;
-
use this script to fetch the warehouse when choosing customer
cur_frm.add_fetch("customer", "warehouse", "warehouse"); -
And use this script to insert the linked warehouse in the warehouse field in the child fields on validate.
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.warehouse } cur_frm.refresh_field('items') });
And that should do it.