mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-14 20:35:09 +00:00
fix: provision to enable naming series for SABB
(cherry picked from commit fe43975cdd)
# Conflicts:
# erpnext/stock/doctype/serial_and_batch_bundle/serial_and_batch_bundle.json
# erpnext/stock/doctype/serial_and_batch_bundle/test_serial_and_batch_bundle.py
# erpnext/stock/doctype/stock_settings/stock_settings.json
This commit is contained in:
committed by
Mergify
parent
38edc46c46
commit
8fbfe14c63
@@ -134,6 +134,13 @@ frappe.ui.form.on("Serial and Batch Bundle", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
toggle_fields(frm) {
|
toggle_fields(frm) {
|
||||||
|
let show_naming_series_field =
|
||||||
|
frappe.user_defaults.set_serial_and_batch_bundle_naming_based_on_naming_series;
|
||||||
|
frm.toggle_display("naming_series", cint(show_naming_series_field));
|
||||||
|
frm.toggle_reqd("naming_series", cint(show_naming_series_field));
|
||||||
|
|
||||||
|
frm.toggle_display("naming_series", frm.doc.__islocal ? true : false);
|
||||||
|
|
||||||
if (frm.doc.has_serial_no) {
|
if (frm.doc.has_serial_no) {
|
||||||
frm.doc.entries.forEach((row) => {
|
frm.doc.entries.forEach((row) => {
|
||||||
if (Math.abs(row.qty) !== 1) {
|
if (Math.abs(row.qty) !== 1) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"item_details_tab",
|
"item_details_tab",
|
||||||
|
"naming_series",
|
||||||
"company",
|
"company",
|
||||||
"item_name",
|
"item_name",
|
||||||
"has_serial_no",
|
"has_serial_no",
|
||||||
@@ -242,12 +243,24 @@
|
|||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Returned Against",
|
"label": "Returned Against",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "SABB-.########",
|
||||||
|
"fieldname": "naming_series",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Naming Series",
|
||||||
|
"options": "\nSABB-.########",
|
||||||
|
"set_only_once": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
|
<<<<<<< HEAD
|
||||||
"modified": "2025-02-12 10:53:32.090309",
|
"modified": "2025-02-12 10:53:32.090309",
|
||||||
|
=======
|
||||||
|
"modified": "2025-02-17 16:22:36.056205",
|
||||||
|
>>>>>>> fe43975cdd (fix: provision to enable naming series for SABB)
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Serial and Batch Bundle",
|
"name": "Serial and Batch Bundle",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from collections import Counter, defaultdict
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _, _dict, bold
|
from frappe import _, _dict, bold
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.model.naming import make_autoname
|
||||||
from frappe.query_builder.functions import CombineDatetime, Sum
|
from frappe.query_builder.functions import CombineDatetime, Sum
|
||||||
from frappe.utils import (
|
from frappe.utils import (
|
||||||
add_days,
|
add_days,
|
||||||
@@ -68,6 +69,7 @@ class SerialandBatchBundle(Document):
|
|||||||
item_code: DF.Link
|
item_code: DF.Link
|
||||||
item_group: DF.Link | None
|
item_group: DF.Link | None
|
||||||
item_name: DF.Data | None
|
item_name: DF.Data | None
|
||||||
|
naming_series: DF.Literal["", "SABB-.########"]
|
||||||
posting_date: DF.Date | None
|
posting_date: DF.Date | None
|
||||||
posting_time: DF.Time | None
|
posting_time: DF.Time | None
|
||||||
returned_against: DF.Data | None
|
returned_against: DF.Data | None
|
||||||
@@ -80,6 +82,24 @@ class SerialandBatchBundle(Document):
|
|||||||
warehouse: DF.Link | None
|
warehouse: DF.Link | None
|
||||||
# end: auto-generated types
|
# end: auto-generated types
|
||||||
|
|
||||||
|
def autoname(self):
|
||||||
|
if frappe.db.get_single_value(
|
||||||
|
"Stock Settings", "set_serial_and_batch_bundle_naming_based_on_naming_series"
|
||||||
|
):
|
||||||
|
if not self.naming_series:
|
||||||
|
frappe.throw(_("Naming Series is mandatory"))
|
||||||
|
|
||||||
|
naming_series = self.naming_series
|
||||||
|
if "#" not in naming_series:
|
||||||
|
naming_series += ".#####"
|
||||||
|
|
||||||
|
self.name = make_autoname(self.naming_series)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
self.name = frappe.generate_hash(length=20)
|
||||||
|
except frappe.DuplicateEntryError:
|
||||||
|
self.autoname()
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if self.docstatus == 1 and self.voucher_detail_no:
|
if self.docstatus == 1 and self.voucher_detail_no:
|
||||||
self.validate_voucher_detail_no()
|
self.validate_voucher_detail_no()
|
||||||
|
|||||||
@@ -16,7 +16,81 @@ from erpnext.stock.doctype.serial_and_batch_bundle.serial_and_batch_bundle impor
|
|||||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
class TestSerialandBatchBundle(FrappeTestCase):
|
class TestSerialandBatchBundle(FrappeTestCase):
|
||||||
|
=======
|
||||||
|
class UnitTestSerialAndBatchBundle(UnitTestCase):
|
||||||
|
"""
|
||||||
|
Unit tests for SerialAndBatchBundle.
|
||||||
|
Use this class for testing individual functions and methods.
|
||||||
|
"""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TestSerialandBatchBundle(IntegrationTestCase):
|
||||||
|
def test_naming_for_sabb(self):
|
||||||
|
frappe.db.set_single_value(
|
||||||
|
"Stock Settings", "set_serial_and_batch_bundle_naming_based_on_naming_series", 1
|
||||||
|
)
|
||||||
|
|
||||||
|
serial_item_code = "New Serial No Valuation 11"
|
||||||
|
make_item(
|
||||||
|
serial_item_code,
|
||||||
|
{
|
||||||
|
"has_serial_no": 1,
|
||||||
|
"serial_no_series": "TEST-A-SER-VAL-.#####",
|
||||||
|
"is_stock_item": 1,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
for sn in ["TEST-A-SER-VAL-00001", "TEST-A-SER-VAL-00002"]:
|
||||||
|
if not frappe.db.exists("Serial No", sn):
|
||||||
|
frappe.get_doc(
|
||||||
|
{
|
||||||
|
"doctype": "Serial No",
|
||||||
|
"serial_no": sn,
|
||||||
|
"item_code": serial_item_code,
|
||||||
|
}
|
||||||
|
).insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
bundle_doc = make_serial_batch_bundle(
|
||||||
|
{
|
||||||
|
"item_code": serial_item_code,
|
||||||
|
"warehouse": "_Test Warehouse - _TC",
|
||||||
|
"voucher_type": "Stock Entry",
|
||||||
|
"posting_date": today(),
|
||||||
|
"posting_time": nowtime(),
|
||||||
|
"qty": 10,
|
||||||
|
"serial_nos": ["TEST-A-SER-VAL-00001", "TEST-A-SER-VAL-00002"],
|
||||||
|
"type_of_transaction": "Inward",
|
||||||
|
"do_not_submit": True,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertTrue(bundle_doc.name.startswith("SABB-"))
|
||||||
|
|
||||||
|
frappe.db.set_single_value(
|
||||||
|
"Stock Settings", "set_serial_and_batch_bundle_naming_based_on_naming_series", 0
|
||||||
|
)
|
||||||
|
|
||||||
|
bundle_doc = make_serial_batch_bundle(
|
||||||
|
{
|
||||||
|
"item_code": serial_item_code,
|
||||||
|
"warehouse": "_Test Warehouse - _TC",
|
||||||
|
"voucher_type": "Stock Entry",
|
||||||
|
"posting_date": today(),
|
||||||
|
"posting_time": nowtime(),
|
||||||
|
"qty": 10,
|
||||||
|
"serial_nos": ["TEST-A-SER-VAL-00001", "TEST-A-SER-VAL-00002"],
|
||||||
|
"type_of_transaction": "Inward",
|
||||||
|
"do_not_submit": True,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertFalse(bundle_doc.name.startswith("SABB-"))
|
||||||
|
|
||||||
|
>>>>>>> fe43975cdd (fix: provision to enable naming series for SABB)
|
||||||
def test_inward_outward_serial_valuation(self):
|
def test_inward_outward_serial_valuation(self):
|
||||||
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note
|
||||||
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt
|
from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import make_purchase_receipt
|
||||||
|
|||||||
@@ -56,6 +56,8 @@
|
|||||||
"use_serial_batch_fields",
|
"use_serial_batch_fields",
|
||||||
"do_not_update_serial_batch_on_creation_of_auto_bundle",
|
"do_not_update_serial_batch_on_creation_of_auto_bundle",
|
||||||
"allow_existing_serial_no",
|
"allow_existing_serial_no",
|
||||||
|
"serial_and_batch_bundle_section",
|
||||||
|
"set_serial_and_batch_bundle_naming_based_on_naming_series",
|
||||||
"stock_planning_tab",
|
"stock_planning_tab",
|
||||||
"auto_material_request",
|
"auto_material_request",
|
||||||
"auto_indent",
|
"auto_indent",
|
||||||
@@ -467,6 +469,27 @@
|
|||||||
"fieldname": "allow_existing_serial_no",
|
"fieldname": "allow_existing_serial_no",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Allow existing Serial No to be Manufactured/Received again"
|
"label": "Allow existing Serial No to be Manufactured/Received again"
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"description": "Upon submission of the Sales Order, Work Order, or Production Plan, the system will automatically reserve the stock.",
|
||||||
|
"fieldname": "auto_reserve_stock",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Auto Reserve Stock"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "serial_and_batch_bundle_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Serial and Batch Bundle"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "set_serial_and_batch_bundle_naming_based_on_naming_series",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Set Serial and Batch Bundle Naming Based on Naming Series"
|
||||||
|
>>>>>>> fe43975cdd (fix: provision to enable naming series for SABB)
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"icon": "icon-cog",
|
"icon": "icon-cog",
|
||||||
@@ -474,7 +497,11 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
|
<<<<<<< HEAD
|
||||||
"modified": "2024-12-09 17:52:36.030456",
|
"modified": "2024-12-09 17:52:36.030456",
|
||||||
|
=======
|
||||||
|
"modified": "2025-02-17 13:36:36.177743",
|
||||||
|
>>>>>>> fe43975cdd (fix: provision to enable naming series for SABB)
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Stock Settings",
|
"name": "Stock Settings",
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class StockSettings(Document):
|
|||||||
role_allowed_to_create_edit_back_dated_transactions: DF.Link | None
|
role_allowed_to_create_edit_back_dated_transactions: DF.Link | None
|
||||||
role_allowed_to_over_deliver_receive: DF.Link | None
|
role_allowed_to_over_deliver_receive: DF.Link | None
|
||||||
sample_retention_warehouse: DF.Link | None
|
sample_retention_warehouse: DF.Link | None
|
||||||
|
set_serial_and_batch_bundle_naming_based_on_naming_series: DF.Check
|
||||||
show_barcode_field: DF.Check
|
show_barcode_field: DF.Check
|
||||||
stock_auth_role: DF.Link | None
|
stock_auth_role: DF.Link | None
|
||||||
stock_frozen_upto: DF.Date | None
|
stock_frozen_upto: DF.Date | None
|
||||||
@@ -75,6 +76,7 @@ class StockSettings(Document):
|
|||||||
"default_warehouse",
|
"default_warehouse",
|
||||||
"set_qty_in_transactions_based_on_serial_no_input",
|
"set_qty_in_transactions_based_on_serial_no_input",
|
||||||
"use_serial_batch_fields",
|
"use_serial_batch_fields",
|
||||||
|
"set_serial_and_batch_bundle_naming_based_on_naming_series",
|
||||||
]:
|
]:
|
||||||
frappe.db.set_default(key, self.get(key, ""))
|
frappe.db.set_default(key, self.get(key, ""))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user