mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
Merge pull request #34304 from ruthra-kumar/ui_freeze_on_item_selection
fix: UI freeze while selecting batched items in sales invoice
This commit is contained in:
@@ -417,7 +417,14 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
args: args,
|
args: args,
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(r.message) {
|
if(r.message) {
|
||||||
frappe.model.set_value(doc.doctype, doc.name, 'batch_no', r.message);
|
if (r.message.batch_no != null) {
|
||||||
|
frappe.model.set_value(doc.doctype, doc.name, 'batch_no', r.message.batch_no);
|
||||||
|
} else if (r.message.msg_print) {
|
||||||
|
frappe.show_alert({
|
||||||
|
message: r.message.msg_print,
|
||||||
|
indicator:'orange'
|
||||||
|
}, 5);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -260,7 +260,9 @@ def set_batch_nos(doc, warehouse_field, throw=False, child_table="items"):
|
|||||||
warehouse = d.get(warehouse_field, None)
|
warehouse = d.get(warehouse_field, None)
|
||||||
if warehouse and qty > 0 and frappe.db.get_value("Item", d.item_code, "has_batch_no"):
|
if warehouse and qty > 0 and frappe.db.get_value("Item", d.item_code, "has_batch_no"):
|
||||||
if not d.batch_no:
|
if not d.batch_no:
|
||||||
d.batch_no = get_batch_no(d.item_code, warehouse, qty, throw, d.serial_no)
|
d.batch_no = get_batch_no(d.item_code, warehouse, qty, throw, d.serial_no).get(
|
||||||
|
"batch_no", None
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
batch_qty = get_batch_qty(batch_no=d.batch_no, warehouse=warehouse)
|
batch_qty = get_batch_qty(batch_no=d.batch_no, warehouse=warehouse)
|
||||||
if flt(batch_qty, d.precision("qty")) < flt(qty, d.precision("qty")):
|
if flt(batch_qty, d.precision("qty")) < flt(qty, d.precision("qty")):
|
||||||
@@ -282,6 +284,7 @@ def get_batch_no(item_code, warehouse, qty=1, throw=False, serial_no=None):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
batch_no = None
|
batch_no = None
|
||||||
|
message = None
|
||||||
batches = get_batches(item_code, warehouse, qty, throw, serial_no)
|
batches = get_batches(item_code, warehouse, qty, throw, serial_no)
|
||||||
|
|
||||||
for batch in batches:
|
for batch in batches:
|
||||||
@@ -290,15 +293,18 @@ def get_batch_no(item_code, warehouse, qty=1, throw=False, serial_no=None):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if not batch_no:
|
if not batch_no:
|
||||||
frappe.msgprint(
|
message = _(
|
||||||
_(
|
"Please select a Batch for Item {0}. Unable to find a single batch that fulfills this requirement"
|
||||||
"Please select a Batch for Item {0}. Unable to find a single batch that fulfills this requirement"
|
).format(frappe.bold(item_code))
|
||||||
).format(frappe.bold(item_code))
|
|
||||||
)
|
|
||||||
if throw:
|
if throw:
|
||||||
|
frappe.msgprint(
|
||||||
|
_(
|
||||||
|
"Please select a Batch for Item {0}. Unable to find a single batch that fulfills this requirement"
|
||||||
|
).format(frappe.bold(item_code))
|
||||||
|
)
|
||||||
raise UnableToSelectBatchError
|
raise UnableToSelectBatchError
|
||||||
|
|
||||||
return batch_no
|
return {"batch_no": batch_no, "msg_print": message}
|
||||||
|
|
||||||
|
|
||||||
def get_batches(item_code, warehouse, qty=1, throw=False, serial_no=None):
|
def get_batches(item_code, warehouse, qty=1, throw=False, serial_no=None):
|
||||||
|
|||||||
@@ -99,7 +99,8 @@ class TestBatch(FrappeTestCase):
|
|||||||
|
|
||||||
# shipped from FEFO batch
|
# shipped from FEFO batch
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
delivery_note.items[0].batch_no, get_batch_no(item_code, receipt.items[0].warehouse, batch_qty)
|
delivery_note.items[0].batch_no,
|
||||||
|
get_batch_no(item_code, receipt.items[0].warehouse, batch_qty).get("batch_no", None),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_delivery_note_fail(self):
|
def test_delivery_note_fail(self):
|
||||||
@@ -145,7 +146,8 @@ class TestBatch(FrappeTestCase):
|
|||||||
|
|
||||||
# assert same batch is selected
|
# assert same batch is selected
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
stock_entry.items[0].batch_no, get_batch_no(item_code, receipt.items[0].warehouse, batch_qty)
|
stock_entry.items[0].batch_no,
|
||||||
|
get_batch_no(item_code, receipt.items[0].warehouse, batch_qty).get("batch_no", None),
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_batch_split(self):
|
def test_batch_split(self):
|
||||||
|
|||||||
@@ -1262,7 +1262,9 @@ class StockEntry(StockController):
|
|||||||
and ret.get("has_batch_no")
|
and ret.get("has_batch_no")
|
||||||
and not args.get("batch_no")
|
and not args.get("batch_no")
|
||||||
):
|
):
|
||||||
args.batch_no = get_batch_no(args["item_code"], args["s_warehouse"], args["qty"])
|
args.batch_no = get_batch_no(args["item_code"], args["s_warehouse"], args["qty"]).get(
|
||||||
|
"batch_no", None
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
self.purpose == "Send to Subcontractor" and self.get("purchase_order") and args.get("item_code")
|
self.purpose == "Send to Subcontractor" and self.get("purchase_order") and args.get("item_code")
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ def update_stock(args, out):
|
|||||||
):
|
):
|
||||||
|
|
||||||
if out.has_batch_no and not args.get("batch_no"):
|
if out.has_batch_no and not args.get("batch_no"):
|
||||||
out.batch_no = get_batch_no(out.item_code, out.warehouse, out.qty)
|
out.batch_no = get_batch_no(out.item_code, out.warehouse, out.qty).get("batch_no", None)
|
||||||
actual_batch_qty = get_batch_qty(out.batch_no, out.warehouse, out.item_code)
|
actual_batch_qty = get_batch_qty(out.batch_no, out.warehouse, out.item_code)
|
||||||
if actual_batch_qty:
|
if actual_batch_qty:
|
||||||
out.update(actual_batch_qty)
|
out.update(actual_batch_qty)
|
||||||
|
|||||||
Reference in New Issue
Block a user