From a4cbfabe0ee4c8fca3ac654e6b3fe3db8b551334 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Mon, 19 Feb 2024 10:25:36 +0530 Subject: [PATCH] fix: do not empty serial batch fields (#39948) --- erpnext/controllers/stock_controller.py | 6 +++--- erpnext/public/js/controllers/buying.js | 4 ++-- erpnext/public/js/utils/sales_common.js | 2 +- erpnext/stock/doctype/pick_list/pick_list.js | 2 +- .../stock/doctype/purchase_receipt/test_purchase_receipt.py | 2 +- erpnext/stock/doctype/stock_entry/stock_entry.js | 2 +- erpnext/stock/doctype/stock_entry/test_stock_entry.py | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index dd272004040c..dc5ce5e6b58b 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -162,6 +162,9 @@ def make_bundle_using_old_serial_batch_fields(self): 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 @@ def make_bundle_using_old_serial_batch_fields(self): row.db_set( { "rejected_serial_and_batch_bundle": sn_doc.name, - "rejected_serial_no": "", } ) else: @@ -227,8 +229,6 @@ def make_bundle_using_old_serial_batch_fields(self): 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 77ecf75e0c52..b3d301d988ad 100644 --- a/erpnext/public/js/controllers/buying.js +++ b/erpnext/public/js/controllers/buying.js @@ -368,7 +368,7 @@ erpnext.buying = { 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 @@ erpnext.buying = { 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 b8ec77f8e529..4bb78433ae64 100644 --- a/erpnext/public/js/utils/sales_common.js +++ b/erpnext/public/js/utils/sales_common.js @@ -339,7 +339,7 @@ erpnext.sales_common = { 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 3cc2956e96b8..056cd5cc99a0 100644 --- a/erpnext/stock/doctype/pick_list/pick_list.js +++ b/erpnext/stock/doctype/pick_list/pick_list.js @@ -330,7 +330,7 @@ frappe.ui.form.on('Pick List Item', { 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 2d209220de22..3afed4b1aa36 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 @@ def test_use_serial_batch_fields_for_serial_nos(self): ) 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 6753a3a21609..8c762915d406 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -1178,7 +1178,7 @@ erpnext.stock.select_batch_and_serial_no = (frm, item) => { 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 6c3faa64991d..99c050afa259 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 @@ def test_use_serial_and_batch_fields(self): ) 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 @@ def test_use_serial_and_batch_fields(self): 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: