fix: do not empty serial batch fields (#39948)
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index dd27200..dc5ce5e 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -162,6 +162,9 @@
from erpnext.stock.doctype.serial_no.serial_no import get_serial_nos
from erpnext.stock.serial_batch_bundle import SerialBatchCreation
+ if self.get("_action") == "update_after_submit":
+ return
+
# To handle test cases
if frappe.flags.in_test and frappe.flags.use_serial_and_batch_fields:
return
@@ -219,7 +222,6 @@
row.db_set(
{
"rejected_serial_and_batch_bundle": sn_doc.name,
- "rejected_serial_no": "",
}
)
else:
@@ -227,8 +229,6 @@
row.db_set(
{
"serial_and_batch_bundle": sn_doc.name,
- "serial_no": "",
- "batch_no": "",
}
)
diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js
index 77ecf75..b3d301d 100644
--- a/erpnext/public/js/controllers/buying.js
+++ b/erpnext/public/js/controllers/buying.js
@@ -368,7 +368,7 @@
let update_values = {
"serial_and_batch_bundle": r.name,
- "qty": qty
+ "qty": qty / flt(item.conversion_factor || 1, precision("conversion_factor", item))
}
if (r.warehouse) {
@@ -408,7 +408,7 @@
let update_values = {
"serial_and_batch_bundle": r.name,
- "rejected_qty": qty
+ "rejected_qty": qty / flt(item.conversion_factor || 1, precision("conversion_factor", item))
}
if (r.warehouse) {
diff --git a/erpnext/public/js/utils/sales_common.js b/erpnext/public/js/utils/sales_common.js
index b8ec77f..4bb7843 100644
--- a/erpnext/public/js/utils/sales_common.js
+++ b/erpnext/public/js/utils/sales_common.js
@@ -339,7 +339,7 @@
frappe.model.set_value(item.doctype, item.name, {
"serial_and_batch_bundle": r.name,
- "qty": qty
+ "qty": qty / flt(item.conversion_factor || 1, precision("conversion_factor", item))
});
}
}
diff --git a/erpnext/stock/doctype/pick_list/pick_list.js b/erpnext/stock/doctype/pick_list/pick_list.js
index 3cc2956..056cd5c 100644
--- a/erpnext/stock/doctype/pick_list/pick_list.js
+++ b/erpnext/stock/doctype/pick_list/pick_list.js
@@ -330,7 +330,7 @@
let qty = Math.abs(r.total_qty);
frappe.model.set_value(item.doctype, item.name, {
"serial_and_batch_bundle": r.name,
- "qty": qty
+ "qty": qty / flt(item.conversion_factor || 1, precision("conversion_factor", item))
});
}
}
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index 2d20922..3afed4b 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -2259,7 +2259,7 @@
)
self.assertEqual(pr.items[0].use_serial_batch_fields, 1)
- self.assertFalse(pr.items[0].serial_no)
+ self.assertTrue(pr.items[0].serial_no)
self.assertTrue(pr.items[0].serial_and_batch_bundle)
sbb_doc = frappe.get_doc("Serial and Batch Bundle", pr.items[0].serial_and_batch_bundle)
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 6753a3a..8c76291 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -1178,7 +1178,7 @@
if (r) {
frappe.model.set_value(item.doctype, item.name, {
"serial_and_batch_bundle": r.name,
- "qty": Math.abs(r.total_qty)
+ "qty": Math.abs(r.total_qty) / flt(item.conversion_factor || 1, precision("conversion_factor", item))
});
}
}
diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
index 6c3faa6..99c050a 100644
--- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
@@ -1775,7 +1775,7 @@
)
self.assertTrue(se.items[0].use_serial_batch_fields)
- self.assertFalse(se.items[0].serial_no)
+ self.assertTrue(se.items[0].serial_no)
self.assertTrue(se.items[0].serial_and_batch_bundle)
for serial_no in serial_nos:
@@ -1793,7 +1793,7 @@
se1.reload()
self.assertTrue(se1.items[0].use_serial_batch_fields)
- self.assertFalse(se1.items[0].serial_no)
+ self.assertTrue(se1.items[0].serial_no)
self.assertTrue(se1.items[0].serial_and_batch_bundle)
for serial_no in serial_nos: