diff --git a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.json b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.json index ad2889d0a0..b92579eb79 100644 --- a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.json +++ b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.json @@ -654,7 +654,7 @@ { "depends_on": "eval:doc.use_serial_batch_fields === 1", "fieldname": "serial_no", - "fieldtype": "Small Text", + "fieldtype": "Text", "hidden": 1, "in_list_view": 1, "label": "Serial No", @@ -853,7 +853,7 @@ ], "istable": 1, "links": [], - "modified": "2024-02-04 16:36:25.665743", + "modified": "2024-02-25 15:50:17.140269", "modified_by": "Administrator", "module": "Accounts", "name": "POS Invoice Item", diff --git a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py index 55a577b0c5..c24db1d6a0 100644 --- a/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py +++ b/erpnext/accounts/doctype/pos_invoice_item/pos_invoice_item.py @@ -72,7 +72,7 @@ class POSInvoiceItem(Document): rate_with_margin: DF.Currency sales_order: DF.Link | None serial_and_batch_bundle: DF.Link | None - serial_no: DF.SmallText | None + serial_no: DF.Text | None service_end_date: DF.Date | None service_start_date: DF.Date | None service_stop_date: DF.Date | None diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json index d06c7861da..e7536e9bb9 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.json @@ -625,7 +625,7 @@ { "depends_on": "eval: doc.use_serial_batch_fields === 1 && parent.update_stock === 1", "fieldname": "serial_no", - "fieldtype": "Small Text", + "fieldtype": "Text", "label": "Serial No", "oldfieldname": "serial_no", "oldfieldtype": "Small Text" @@ -926,7 +926,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2024-02-04 11:52:16.106541", + "modified": "2024-02-25 15:56:44.828634", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice Item", diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py index c71d08e7f7..9be1b42aab 100644 --- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py +++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py @@ -75,7 +75,7 @@ class SalesInvoiceItem(Document): sales_invoice_item: DF.Data | None sales_order: DF.Link | None serial_and_batch_bundle: DF.Link | None - serial_no: DF.SmallText | None + serial_no: DF.Text | None service_end_date: DF.Date | None service_start_date: DF.Date | None service_stop_date: DF.Date | None diff --git a/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.json b/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.json index 8eda441781..f79a84855d 100644 --- a/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.json +++ b/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.json @@ -107,7 +107,7 @@ { "depends_on": "eval:doc.use_serial_batch_fields === 1", "fieldname": "serial_no", - "fieldtype": "Small Text", + "fieldtype": "Text", "hidden": 1, "label": "Serial No", "print_hide": 1 @@ -178,7 +178,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-02-04 16:41:09.239762", + "modified": "2024-02-25 15:57:35.007501", "modified_by": "Administrator", "module": "Assets", "name": "Asset Capitalization Stock Item", diff --git a/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.py b/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.py index d2b075c3e6..0f06cc7442 100644 --- a/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.py +++ b/erpnext/assets/doctype/asset_capitalization_stock_item/asset_capitalization_stock_item.py @@ -24,7 +24,7 @@ class AssetCapitalizationStockItem(Document): parentfield: DF.Data parenttype: DF.Data serial_and_batch_bundle: DF.Link | None - serial_no: DF.SmallText | None + serial_no: DF.Text | None stock_qty: DF.Float stock_uom: DF.Link use_serial_batch_fields: DF.Check diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py index a1a34dba66..7b6cea5990 100644 --- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -2200,6 +2200,10 @@ class TestPurchaseReceipt(FrappeTestCase): create_stock_reconciliation, ) + frappe.db.set_single_value( + "Stock Settings", "do_not_update_serial_batch_on_creation_of_auto_bundle", 0 + ) + item_code = make_item( "_Test Use Serial Fields Item Serial Item", properties={"has_serial_no": 1, "serial_no_series": "SNU-TSFISI-.#####"}, @@ -2280,30 +2284,10 @@ class TestPurchaseReceipt(FrappeTestCase): serial_no_status = frappe.db.get_value("Serial No", sn, "status") self.assertTrue(serial_no_status != "Active") - def test_auto_set_batch_based_on_bundle(self): - item_code = make_item( - "_Test Auto Set Batch Based on Bundle", - properties={ - "has_batch_no": 1, - "batch_number_series": "BATCH-BNU-TASBBB-.#####", - "create_new_batch": 1, - }, - ).name - - frappe.db.set_single_value("Stock Settings", "use_serial_batch_fields", 1) - - pr = make_purchase_receipt( - item_code=item_code, - qty=5, - rate=100, + frappe.db.set_single_value( + "Stock Settings", "do_not_update_serial_batch_on_creation_of_auto_bundle", 1 ) - self.assertTrue(pr.items[0].batch_no) - batch_no = get_batch_from_bundle(pr.items[0].serial_and_batch_bundle) - self.assertEqual(pr.items[0].batch_no, batch_no) - - frappe.db.set_single_value("Stock Settings", "use_serial_batch_fields", 0) - def test_sle_qty_after_transaction(self): item = make_item( "_Test Item Qty After Transaction", @@ -2393,6 +2377,34 @@ class TestPurchaseReceipt(FrappeTestCase): for index, d in enumerate(data): self.assertEqual(d.qty_after_transaction, 11 + index) + def test_auto_set_batch_based_on_bundle(self): + item_code = make_item( + "_Test Auto Set Batch Based on Bundle", + properties={ + "has_batch_no": 1, + "batch_number_series": "BATCH-BNU-TASBBB-.#####", + "create_new_batch": 1, + }, + ).name + + frappe.db.set_single_value( + "Stock Settings", "do_not_update_serial_batch_on_creation_of_auto_bundle", 0 + ) + + pr = make_purchase_receipt( + item_code=item_code, + qty=5, + rate=100, + ) + + self.assertTrue(pr.items[0].batch_no) + batch_no = get_batch_from_bundle(pr.items[0].serial_and_batch_bundle) + self.assertEqual(pr.items[0].batch_no, batch_no) + + frappe.db.set_single_value( + "Stock Settings", "do_not_update_serial_batch_on_creation_of_auto_bundle", 1 + ) + def prepare_data_for_internal_transfer(): from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_internal_supplier diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json index c7b3daab82..48fc31ab66 100644 --- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json +++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json @@ -294,7 +294,7 @@ { "depends_on": "eval:doc.use_serial_batch_fields === 1", "fieldname": "serial_no", - "fieldtype": "Small Text", + "fieldtype": "Text", "label": "Serial No", "no_copy": 1, "oldfieldname": "serial_no", @@ -610,7 +610,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2024-02-04 16:16:47.606270", + "modified": "2024-02-25 15:58:40.982582", "modified_by": "Administrator", "module": "Stock", "name": "Stock Entry Detail", diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py index 47c443c519..bd3dda1b98 100644 --- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py +++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py @@ -54,7 +54,7 @@ class StockEntryDetail(Document): sample_quantity: DF.Int sco_rm_detail: DF.Data | None serial_and_batch_bundle: DF.Link | None - serial_no: DF.SmallText | None + serial_no: DF.Text | None set_basic_rate_manually: DF.Check ste_detail: DF.Data | None stock_uom: DF.Link diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.json b/erpnext/stock/doctype/stock_settings/stock_settings.json index 1e8d0ddbb3..d972d595e8 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.json +++ b/erpnext/stock/doctype/stock_settings/stock_settings.json @@ -51,6 +51,7 @@ "use_naming_series", "naming_series_prefix", "use_serial_batch_fields", + "do_not_update_serial_batch_on_creation_of_auto_bundle", "stock_planning_tab", "auto_material_request", "auto_indent", @@ -428,6 +429,14 @@ "fieldname": "use_serial_batch_fields", "fieldtype": "Check", "label": "Use Serial / Batch Fields" + }, + { + "default": "1", + "depends_on": "use_serial_batch_fields", + "description": "If enabled, do not update serial / batch values in the stock transactions on creation of auto Serial \n / Batch Bundle. ", + "fieldname": "do_not_update_serial_batch_on_creation_of_auto_bundle", + "fieldtype": "Check", + "label": "Do Not Update Serial / Batch on Creation of Auto Bundle" } ], "icon": "icon-cog", @@ -435,7 +444,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2024-02-24 12:50:51.740097", + "modified": "2024-02-25 16:32:01.084453", "modified_by": "Administrator", "module": "Stock", "name": "Stock Settings", diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.py b/erpnext/stock/doctype/stock_settings/stock_settings.py index c4960aa67a..d975c29ee5 100644 --- a/erpnext/stock/doctype/stock_settings/stock_settings.py +++ b/erpnext/stock/doctype/stock_settings/stock_settings.py @@ -39,6 +39,7 @@ class StockSettings(Document): clean_description_html: DF.Check default_warehouse: DF.Link | None disable_serial_no_and_batch_selector: DF.Check + do_not_update_serial_batch_on_creation_of_auto_bundle: DF.Check enable_stock_reservation: DF.Check item_group: DF.Link | None item_naming_by: DF.Literal["Item Code", "Naming Series"] diff --git a/erpnext/stock/serial_batch_bundle.py b/erpnext/stock/serial_batch_bundle.py index 52c5b000a7..24dd9d1d20 100644 --- a/erpnext/stock/serial_batch_bundle.py +++ b/erpnext/stock/serial_batch_bundle.py @@ -142,7 +142,9 @@ class SerialBatchBundle: "serial_and_batch_bundle": sn_doc.name, } - if frappe.db.get_single_value("Stock Settings", "use_serial_batch_fields"): + if not frappe.db.get_single_value( + "Stock Settings", "do_not_update_serial_batch_on_creation_of_auto_bundle" + ): if sn_doc.has_serial_no: values_to_update["serial_no"] = ",".join(cstr(d.serial_no) for d in sn_doc.entries) elif sn_doc.has_batch_no and len(sn_doc.entries) == 1: