[minor]
diff --git a/erpnext/stock/doctype/batch/test_batch.py b/erpnext/stock/doctype/batch/test_batch.py
index cd621cc..eb3b48e 100644
--- a/erpnext/stock/doctype/batch/test_batch.py
+++ b/erpnext/stock/doctype/batch/test_batch.py
@@ -17,10 +17,11 @@
"item": "_Test Item"
}).save)
- def make_batch_item(self, item_name):
+ @classmethod
+ def make_batch_item(cls, item_name):
from erpnext.stock.doctype.item.test_item import make_item
if not frappe.db.exists(item_name):
- make_item(item_name, dict(has_batch_no = 1))
+ make_item(item_name, dict(has_batch_no = 1, create_new_batch = 1))
def test_purchase_receipt(self, batch_qty = 100):
'''Test automated batch creation from Purchase Receipt'''
@@ -162,7 +163,8 @@
self.assertEquals(get_batch_qty('batch a', '_Test Warehouse - _TC'), 90)
- def make_new_batch_and_entry(self, item_name, batch_name, warehouse):
+ @classmethod
+ def make_new_batch_and_entry(cls, item_name, batch_name, warehouse):
'''Make a new stock entry for given target warehouse and batch name of item'''
if not frappe.db.exists("Batch", batch_name):
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 2c96541..1f4fdf1 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -548,49 +548,16 @@
erpnext.stock.select_batch_and_serial_no = (frm, d = undefined) => {
let get_warehouse = (item) => {
+ let value = '';
if(frm.fields_dict.from_warehouse.disp_status === "Write") {
- var value = cstr(item.s_warehouse) || '';
+ value = cstr(item.s_warehouse) || '';
return ['Source Warehouse', value];
} else {
- var value = cstr(item.t_warehouse) || '';
+ value = cstr(item.t_warehouse) || '';
return ['Target Warehouse', value];
}
}
- let show_modal_with_oldest_batch = (item, item_code, total_qty, warehouse_details, has_batch) => {
- frappe.call({
- method: 'erpnext.stock.doctype.batch.batch.get_batches_by_oldest',
- args: {
- warehouse: warehouse_details[1],
- item_code: item_code
- },
- callback: (r) => {
- if (r.message) {
- var batch_rows_by_oldest = [];
- if(warehouse_details[0] === 'Source Warehouse') {
- var qty = total_qty;
- for(var i = 0; i < r.message.length; i++) {
- var batch_row = {name: 'batch 1'};
- batch_row.batch_no = r.message[i].batch_no;
- batch_row.available_qty = r.message[i].qty;
- if (parseInt(qty) <= parseInt(r.message[i].qty)) {
- batch_row.selected_qty = qty;
- batch_rows_by_oldest.push(batch_row);
- break;
- } else {
- batch_row.selected_qty = r.message[i].qty;
- qty -= r.message[i].qty;
- batch_rows_by_oldest.push(batch_row);
- }
- }
- }
- erpnext.stock.show_batch_serial_modal(frm, item, item_code, total_qty,
- warehouse_details, has_batch, batch_rows_by_oldest);
- }
- }
- });
- }
-
if(d && d.has_batch_no && !d.batch_no) {
// show_modal_with_oldest_batch(d, d.item_code, d.qty, get_warehouse(d), 1);
erpnext.stock.show_batch_serial_modal(frm, d, d.item_code, d.qty, get_warehouse(d), 1);
@@ -621,7 +588,7 @@
{fieldname: 'batches', fieldtype: 'Table',
fields: [
{fieldtype:'Link', fieldname:'batch_no', options: 'Batch',
- label: __('Select Batch'), in_list_view:1, get_query: function(doc) {
+ label: __('Select Batch'), in_list_view:1, get_query: function() {
return {filters: {item: item_code }};
}},
{fieldtype:'Float', read_only:1, fieldname:'available_qty',
@@ -644,7 +611,7 @@
{
fieldtype: 'Link', fieldname: 'serial_no_select', options: 'Serial No',
label: __('Select'),
- get_query: function(doc) {
+ get_query: function() {
return { filters: {item_code: item_code}};
}
},
@@ -694,7 +661,7 @@
if(i === 0) {
map_item_values(item, values, 'batch_no');
} else {
- var row = frm.add_child("items");
+ let row = frm.add_child("items");
row.item_code = item.item_code;
map_item_values(row, values, 'batch_no');
}
@@ -746,7 +713,7 @@
});
qty_field.set_input(total_qty);
} else {
- var serial_numbers = serial_no_list_field.get_value().replace(/\n/g, ' ').match(/\S+/g) || [];
+ let serial_numbers = serial_no_list_field.get_value().replace(/\n/g, ' ').match(/\S+/g) || [];
qty_field.set_input(serial_numbers.length);
}
}
@@ -849,7 +816,7 @@
let name = $row.attr('data-name');
let row = batches_field.grid.grid_rows_by_docname[name];
- var field = row.on_grid_fields_dict[fieldname];
+ let field = row.on_grid_fields_dict[fieldname];
field.$input.trigger('blur');
row.doc[fieldname] = field.get_value();
batches_field.grid.set_value(fieldname, row.doc[fieldname], row.doc);