[fix] tests
This commit is contained in:
parent
a5d5403bf3
commit
36693e27be
@ -153,8 +153,6 @@ class TestBatch(unittest.TestCase):
|
|||||||
|
|
||||||
def test_get_batch_qty(self):
|
def test_get_batch_qty(self):
|
||||||
'''Test getting batch quantities by batch_numbers, item_code or warehouse'''
|
'''Test getting batch quantities by batch_numbers, item_code or warehouse'''
|
||||||
from erpnext.stock.doctype.batch.batch import get_batch_qty
|
|
||||||
|
|
||||||
self.make_batch_item('ITEM-BATCH-2')
|
self.make_batch_item('ITEM-BATCH-2')
|
||||||
self.make_new_batch_and_entry('ITEM-BATCH-2', 'batch a', '_Test Warehouse - _TC')
|
self.make_new_batch_and_entry('ITEM-BATCH-2', 'batch a', '_Test Warehouse - _TC')
|
||||||
self.make_new_batch_and_entry('ITEM-BATCH-2', 'batch b', '_Test Warehouse - _TC')
|
self.make_new_batch_and_entry('ITEM-BATCH-2', 'batch b', '_Test Warehouse - _TC')
|
||||||
|
@ -549,11 +549,11 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
|||||||
erpnext.stock.select_batch_and_serial_no = (frm, d = undefined) => {
|
erpnext.stock.select_batch_and_serial_no = (frm, d = undefined) => {
|
||||||
let get_warehouse = (item) => {
|
let get_warehouse = (item) => {
|
||||||
if(frm.fields_dict.from_warehouse.disp_status === "Write") {
|
if(frm.fields_dict.from_warehouse.disp_status === "Write") {
|
||||||
value = cstr(item.s_warehouse) || ''
|
var value = cstr(item.s_warehouse) || '';
|
||||||
return ['Source Warehouse', value]
|
return ['Source Warehouse', value];
|
||||||
} else {
|
} else {
|
||||||
value = cstr(item.t_warehouse) || ''
|
var value = cstr(item.t_warehouse) || '';
|
||||||
return ['Target Warehouse', value]
|
return ['Target Warehouse', value];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,11 +566,11 @@ erpnext.stock.select_batch_and_serial_no = (frm, d = undefined) => {
|
|||||||
},
|
},
|
||||||
callback: (r) => {
|
callback: (r) => {
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
batch_rows_by_oldest = [];
|
var batch_rows_by_oldest = [];
|
||||||
if(warehouse_details[0] === 'Source Warehouse') {
|
if(warehouse_details[0] === 'Source Warehouse') {
|
||||||
qty = total_qty;
|
var qty = total_qty;
|
||||||
for(var i = 0; i < r.message.length; i++) {
|
for(var i = 0; i < r.message.length; i++) {
|
||||||
batch_row = {name: 'batch 1'};
|
var batch_row = {name: 'batch 1'};
|
||||||
batch_row.batch_no = r.message[i].batch_no;
|
batch_row.batch_no = r.message[i].batch_no;
|
||||||
batch_row.available_qty = r.message[i].qty;
|
batch_row.available_qty = r.message[i].qty;
|
||||||
if (parseInt(qty) <= parseInt(r.message[i].qty)) {
|
if (parseInt(qty) <= parseInt(r.message[i].qty)) {
|
||||||
@ -602,7 +602,7 @@ erpnext.stock.select_batch_and_serial_no = (frm, d = undefined) => {
|
|||||||
erpnext.stock.show_batch_serial_modal = (frm, item, item_code, qty, warehouse_details,
|
erpnext.stock.show_batch_serial_modal = (frm, item, item_code, qty, warehouse_details,
|
||||||
has_batch, oldest = undefined) => {
|
has_batch, oldest = undefined) => {
|
||||||
|
|
||||||
let data = oldest ? oldest : []
|
let data = oldest ? oldest : [];
|
||||||
let title = "";
|
let title = "";
|
||||||
let fields = [
|
let fields = [
|
||||||
{fieldname: 'item_code', read_only: 1, fieldtype:'Link', options: 'Item',
|
{fieldname: 'item_code', read_only: 1, fieldtype:'Link', options: 'Item',
|
||||||
@ -650,7 +650,7 @@ erpnext.stock.show_batch_serial_modal = (frm, item, item_code, qty, warehouse_de
|
|||||||
},
|
},
|
||||||
{fieldtype: 'Column Break'},
|
{fieldtype: 'Column Break'},
|
||||||
{fieldname: 'serial_no', fieldtype: 'Small Text'}
|
{fieldname: 'serial_no', fieldtype: 'Small Text'}
|
||||||
])
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let dialog = new frappe.ui.Dialog({
|
let dialog = new frappe.ui.Dialog({
|
||||||
@ -746,7 +746,7 @@ erpnext.stock.bind_batch_serial_dialog_qty = (dialog, warehouse_details) => {
|
|||||||
});
|
});
|
||||||
qty_field.set_input(total_qty);
|
qty_field.set_input(total_qty);
|
||||||
} else {
|
} else {
|
||||||
serial_numbers = serial_no_list_field.get_value().replace(/\n/g, ' ').match(/\S+/g) || [];
|
var serial_numbers = serial_no_list_field.get_value().replace(/\n/g, ' ').match(/\S+/g) || [];
|
||||||
qty_field.set_input(serial_numbers.length);
|
qty_field.set_input(serial_numbers.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -773,7 +773,7 @@ erpnext.stock.bind_batch_serial_dialog_qty = (dialog, warehouse_details) => {
|
|||||||
|
|
||||||
if(serial_no_link) {
|
if(serial_no_link) {
|
||||||
let serial_list = [];
|
let serial_list = [];
|
||||||
serial_no_link.$input.on('awesomplete-selectcomplete', function(e) {
|
serial_no_link.$input.on('awesomplete-selectcomplete', function() {
|
||||||
if(serial_no_link.get_value().length > 0) {
|
if(serial_no_link.get_value().length > 0) {
|
||||||
let new_no = serial_no_link.get_value();
|
let new_no = serial_no_link.get_value();
|
||||||
let list_value = serial_no_list_field.get_value();
|
let list_value = serial_no_list_field.get_value();
|
||||||
@ -802,7 +802,7 @@ erpnext.stock.bind_batch_serial_dialog_qty = (dialog, warehouse_details) => {
|
|||||||
|
|
||||||
if(batches_field) {
|
if(batches_field) {
|
||||||
batches_field.grid.add_new_row(null, null, true);
|
batches_field.grid.add_new_row(null, null, true);
|
||||||
batches_field.grid.wrapper.on('change', 'input[data-fieldname="selected_qty"]', function(e) {
|
batches_field.grid.wrapper.on('change', 'input[data-fieldname="selected_qty"]', function() {
|
||||||
// check if batch is selected
|
// check if batch is selected
|
||||||
if($(this).val().length !== 0) {
|
if($(this).val().length !== 0) {
|
||||||
let $row = $(this).closest('.grid-row');
|
let $row = $(this).closest('.grid-row');
|
||||||
@ -825,7 +825,7 @@ erpnext.stock.bind_batch_serial_dialog_qty = (dialog, warehouse_details) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
batches_field.grid.wrapper.on('change', 'input[data-fieldname="batch_no"]', function(e) {
|
batches_field.grid.wrapper.on('change', 'input[data-fieldname="batch_no"]', function() {
|
||||||
let $row = $(this).closest('.grid-row');
|
let $row = $(this).closest('.grid-row');
|
||||||
let name = $row.attr('data-name');
|
let name = $row.attr('data-name');
|
||||||
let row = batches_field.grid.grid_rows_by_docname[name];
|
let row = batches_field.grid.grid_rows_by_docname[name];
|
||||||
@ -839,20 +839,20 @@ erpnext.stock.bind_batch_serial_dialog_qty = (dialog, warehouse_details) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
batches_field.grid.wrapper.on('change', function(e) {
|
batches_field.grid.wrapper.on('change', function() {
|
||||||
update_quantity(1);
|
update_quantity(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
batches_field.grid.wrapper.on('change', 'input', function(e) {
|
batches_field.grid.wrapper.on('change', 'input', function() {
|
||||||
let fieldname = $(this).attr('data-fieldname');
|
let fieldname = $(this).attr('data-fieldname');
|
||||||
let $row = $(this).closest('.grid-row');
|
let $row = $(this).closest('.grid-row');
|
||||||
let name = $row.attr('data-name');
|
let name = $row.attr('data-name');
|
||||||
let row = batches_field.grid.grid_rows_by_docname[name];
|
let row = batches_field.grid.grid_rows_by_docname[name];
|
||||||
|
|
||||||
field = row.on_grid_fields_dict[fieldname];
|
var field = row.on_grid_fields_dict[fieldname];
|
||||||
field.$input.trigger('blur');
|
field.$input.trigger('blur');
|
||||||
row.doc[fieldname] = field.get_value();
|
row.doc[fieldname] = field.get_value();
|
||||||
batches_field.grid.set_value(fieldname, row.doc[fieldname], row.doc)
|
batches_field.grid.set_value(fieldname, row.doc[fieldname], row.doc);
|
||||||
});
|
});
|
||||||
|
|
||||||
warehouse_field.$input.on('change', function() {
|
warehouse_field.$input.on('change', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user