Added Default Warehouse field that sets all item's warehouse (#15462)
* -Added field def_warehouse that sets warehouse of all items
-Grouped warehouse fields together and put raw materies supplied before items table, it will only show if there are any items supplied
* Set def_warehouse in test_sales_order.py
* Changed from def_warehouse to set_warehouse
* Rest of def_warehouse to set_warehouse
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index ca6eb44..f3c29fc 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -98,6 +98,15 @@
frm.cscript.calculate_taxes_and_totals();
});
+ frappe.ui.form.on(this.frm.doctype + " Item", {
+ items_add: function(frm, cdt, cdn) {
+ var item = frappe.get_doc(cdt, cdn);
+ if(!item.warehouse && frm.doc.set_warehouse) {
+ item.warehouse = frm.doc.set_warehouse;
+ }
+ }
+ });
+
var me = this;
if(this.frm.fields_dict["items"].grid.get_field('batch_no')) {
this.frm.set_query("batch_no", "items", function(doc, cdt, cdn) {
@@ -1463,6 +1472,15 @@
}
})
}
+ },
+
+ set_warehouse: function() {
+ var me = this;
+ if(this.frm.doc.set_warehouse) {
+ $.each(this.frm.doc.items || [], function(i, item) {
+ frappe.model.set_value(me.frm.doctype + " Item", item.name, "warehouse", me.frm.doc.set_warehouse);
+ });
+ }
}
});