Add in delivery note
diff --git a/erpnext/public/js/utils/serial_no_batch_selector.js b/erpnext/public/js/utils/serial_no_batch_selector.js
index f54fc0f..dd47f20 100644
--- a/erpnext/public/js/utils/serial_no_batch_selector.js
+++ b/erpnext/public/js/utils/serial_no_batch_selector.js
@@ -58,10 +58,11 @@
this.dialog.set_primary_action(__('Insert'), function() {
me.values = me.dialog.get_values();
- if(!me.validate()) return;
- me.set_items();
- refresh_field("items");
- me.dialog.hide();
+ if(me.validate()) {
+ me.set_items();
+ refresh_field("items");
+ me.dialog.hide();
+ }
});
this.dialog.show();
@@ -120,8 +121,10 @@
item[attribute] = values[attribute];
if(this.warehouse_details.type === 'Source Warehouse') {
item.s_warehouse = values.warehouse || warehouse;
- } else {
+ } else if(this.warehouse_details.type === 'Target Warehouse') {
item.t_warehouse = values.warehouse || warehouse;
+ } else {
+ item.warehouse = values.warehouse || warehouse;
}
item.qty = values[qty_field];
},
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index 5b9fc68..4b52f2f 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -85,8 +85,41 @@
frm.update_in_all_rows('items', 'cost_center', d.cost_center);
},
item_code: function(frm, dt, dn) {
- refresh_field("items");
- erpnext.stock.select_batch_and_serial_no(frm, d);
+ var d = locals[dt][dn];
+ if(d.item_code) {
+ var args = {
+ 'item_code': d.item_code,
+ };
+ frappe.call({
+ doc: frm.doc,
+ method: "get_batched_serialized_details",
+ args: args,
+ callback: function(r) {
+ if(r.message) {
+ $.each(r.message, function(k, v) {
+ d[k] = v;
+ });
+ let opts = {
+ frm: frm,
+ item: d,
+ warehouse_details: {
+ type: "From Warehouse",
+ name: d.warehouse
+ },
+ }
+ if(d && d.has_batch_no && !d.batch_no) {
+ opts.has_batch = 1;
+ } else if(d && d.has_serial_no && !d.serial_no) {
+ opts.has_batch = 0;
+ }
+ if(opts.hasOwnProperty("has_batch")) {
+ let serial_no_batch_selector = new erpnext.SerialNoBatchSelector(opts);
+ }
+ refresh_field("items");
+ }
+ }
+ });
+ }
}
});
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index 7523409..e176117 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -301,6 +301,24 @@
self.load_from_db()
+ def get_batched_serialized_details(self, item_code):
+ item = frappe.db.sql("""
+ select
+ has_serial_no,
+ has_batch_no
+ from
+ `tabItem`
+ where
+ name = %s""",
+ (item_code), as_dict = 1)
+
+ item = item[0]
+
+ return frappe._dict({
+ 'has_serial_no' : item.has_serial_no,
+ 'has_batch_no' : item.has_batch_no
+ })
+
def update_billed_amount_based_on_so(so_detail, update_modified=True):
# Billed against Sales Order directly
billed_against_so = frappe.db.sql("""select sum(amount) from `tabSales Invoice Item`
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 1504f71..34f5cb7 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -175,8 +175,8 @@
$.each(r.message, function(k, v) {
d[k] = v;
});
- refresh_field("items");
erpnext.stock.select_batch_and_serial_no(frm, d);
+ refresh_field("items");
}
}
});
@@ -578,6 +578,7 @@
opts.has_batch = 0;
}
- let serial_no_batch_selector = new erpnext.SerialNoBatchSelector(opts);
-
+ if(opts.hasOwnProperty("has_batch")) {
+ let serial_no_batch_selector = new erpnext.SerialNoBatchSelector(opts);
+ }
}