* fix: Data too long for column 'serial_no' at row 1 (#40098) (cherry picked from commit 08caa7cfa15912f8b45d97088fed30c32e55db29) # Conflicts: # erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py * chore: fix conflicts --------- Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
parent
ad53633c66
commit
9d19ec43c8
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
@ -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
|
||||
|
@ -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",
|
||||
|
@ -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"]
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user