enhancement`: Added Set Reserve Warehouse field in Purchase Order. (#19991)
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json
index 5dce349..8cd44c7 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.json
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.json
@@ -1,4 +1,5 @@
{
+ "actions": [],
"allow_import": 1,
"autoname": "naming_series:",
"creation": "2013-05-21 16:16:39",
@@ -47,6 +48,7 @@
"ignore_pricing_rule",
"sec_warehouse",
"set_warehouse",
+ "set_reserve_warehouse",
"col_break_warehouse",
"is_subcontracted",
"supplier_warehouse",
@@ -1039,12 +1041,20 @@
"fieldtype": "Link",
"label": "Tax Category",
"options": "Tax Category"
+ },
+ {
+ "depends_on": "supplied_items",
+ "fieldname": "set_reserve_warehouse",
+ "fieldtype": "Link",
+ "label": "Set Reserve Warehouse",
+ "options": "Warehouse"
}
],
"icon": "fa fa-file-text",
"idx": 105,
"is_submittable": 1,
- "modified": "2019-07-11 18:25:49.509343",
+ "links": [],
+ "modified": "2019-12-18 13:13:22.852412",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order",
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 6db849a..6ca0958 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -1775,14 +1775,28 @@
}
},
+ set_reserve_warehouse: function() {
+ this.autofill_warehouse("reserve_warehouse");
+ },
+
set_warehouse: function() {
+ this.autofill_warehouse("warehouse");
+ },
+
+ autofill_warehouse : function (warehouse_field) {
+ // set warehouse in all child table rows
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);
+ let warehouse = (warehouse_field === "warehouse") ? me.frm.doc.set_warehouse : me.frm.doc.set_reserve_warehouse;
+ let child_table = (warehouse_field === "warehouse") ? me.frm.doc.items : me.frm.doc.supplied_items;
+ let doctype = (warehouse_field === "warehouse") ? (me.frm.doctype + " Item") : (me.frm.doctype + " Item Supplied");
+
+ if(warehouse) {
+ $.each(child_table || [], function(i, item) {
+ frappe.model.set_value(doctype, item.name, warehouse_field, warehouse);
});
}
},
+
coupon_code: function() {
var me = this;
frappe.run_serially([