Set warehouse automatically based on company

Hello,

I’m trying to fill the delivery warehouse automaticaly on sales orders according to the company selected.

Looking on this topic Not able to update value in child table [Solved] I’ve found part of the solution, but I am missing the method and args.

frappe.ui.form.on(“Sales Order”, “default_delivery_warehouse”, function(frm,cdt,cdn) {
var d = locals[cdt][cdn];
var p = frm.doc;
frappe.call({
method: {method},
args: {args},
callback: function® {
$.each(cur_frm.doc.items || [], function(i, item) {
item.warehouse = r.message
frappe.model.set_value(d.doctype, d.name, “warehouse”,r.message);
});
refresh_field(“items”);
}
})
});

Thanks in advance to the community

Where do you get information about the company warehouses?

ps. Please don’t thank in advance!

Hello @rmehta,

Right now is a link field like “Default Source Warehouse” on Stock Entry, I would like the same behavior on sales order.

But I intend to put the default information (source, finished goods, delivery warehouses) on company master and autofill the fields on stock entry, sales orders, purchase orders and other docs, company-wise defaults would speed up the process of filling a order.

I don’t know if its the best approach.

Try this option:

@mrmo

It worked! Thank you!

Can we do this based on warehouse that had link with user through role permission manager? Please guide me. Thank you.