Skip to content

Commit d047c96

Browse files
Merge pull request #46990 from frappe/mergify/bp/version-15/pr-46947
feat: available serial no report (backport #46383) (backport #46947)
2 parents 72e9844 + 88f1cf2 commit d047c96

6 files changed

Lines changed: 530 additions & 0 deletions

File tree

erpnext/stock/doctype/serial_no/serial_no.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ def get_serial_nos(serial_no):
149149
return [s.strip() for s in cstr(serial_no).strip().replace(",", "\n").split("\n") if s.strip()]
150150

151151

152+
def get_serial_nos_from_sle_list(bundles):
153+
table = frappe.qb.DocType("Serial and Batch Entry")
154+
query = frappe.qb.from_(table).select(table.parent, table.serial_no).where(table.parent.isin(bundles))
155+
data = query.run(as_dict=True)
156+
157+
result = {}
158+
for d in data:
159+
result.setdefault(d.parent, []).append(d.serial_no)
160+
return result
161+
162+
152163
def clean_serial_no_string(serial_no: str) -> str:
153164
if not serial_no:
154165
return ""

erpnext/stock/report/available_serial_no/__init__.py

Whitespace-only changes.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
2+
// License: GNU General Public License v3. See license.txt
3+
4+
frappe.query_reports["Available Serial No"] = {
5+
filters: [
6+
{
7+
fieldname: "company",
8+
label: __("Company"),
9+
fieldtype: "Link",
10+
options: "Company",
11+
default: frappe.defaults.get_user_default("Company"),
12+
reqd: 1,
13+
},
14+
{
15+
fieldname: "from_date",
16+
label: __("From Date"),
17+
fieldtype: "Date",
18+
default: frappe.datetime.add_months(frappe.datetime.get_today(), -1),
19+
reqd: 1,
20+
},
21+
{
22+
fieldname: "to_date",
23+
label: __("To Date"),
24+
fieldtype: "Date",
25+
default: frappe.datetime.get_today(),
26+
reqd: 1,
27+
},
28+
{
29+
fieldname: "warehouse",
30+
label: __("Warehouse"),
31+
fieldtype: "Link",
32+
options: "Warehouse",
33+
get_query: function () {
34+
const company = frappe.query_report.get_filter_value("company");
35+
return {
36+
filters: { company: company },
37+
};
38+
},
39+
},
40+
{
41+
fieldname: "item_code",
42+
label: __("Item"),
43+
fieldtype: "Link",
44+
options: "Item",
45+
get_query: function () {
46+
return {
47+
query: "erpnext.controllers.queries.item_query",
48+
filters: {
49+
has_serial_no: 1,
50+
},
51+
};
52+
},
53+
},
54+
{
55+
fieldname: "item_group",
56+
label: __("Item Group"),
57+
fieldtype: "Link",
58+
options: "Item Group",
59+
},
60+
{
61+
fieldname: "batch_no",
62+
label: __("Batch No"),
63+
fieldtype: "Link",
64+
options: "Batch",
65+
on_change() {
66+
const batch_no = frappe.query_report.get_filter_value("batch_no");
67+
if (batch_no) {
68+
frappe.query_report.set_filter_value("segregate_serial_batch_bundle", 1);
69+
} else {
70+
frappe.query_report.set_filter_value("segregate_serial_batch_bundle", 0);
71+
}
72+
},
73+
},
74+
{
75+
fieldname: "brand",
76+
label: __("Brand"),
77+
fieldtype: "Link",
78+
options: "Brand",
79+
},
80+
{
81+
fieldname: "voucher_no",
82+
label: __("Voucher #"),
83+
fieldtype: "Data",
84+
},
85+
{
86+
fieldname: "project",
87+
label: __("Project"),
88+
fieldtype: "Link",
89+
options: "Project",
90+
},
91+
{
92+
fieldname: "include_uom",
93+
label: __("Include UOM"),
94+
fieldtype: "Link",
95+
options: "UOM",
96+
},
97+
{
98+
fieldname: "valuation_field_type",
99+
label: __("Valuation Field Type"),
100+
fieldtype: "Select",
101+
width: "80",
102+
options: "Currency\nFloat",
103+
default: "Currency",
104+
},
105+
],
106+
formatter: function (value, row, column, data, default_formatter) {
107+
value = default_formatter(value, row, column, data);
108+
if (column.fieldname == "out_qty" && data && data.out_qty < 0) {
109+
value = "<span style='color:red'>" + value + "</span>";
110+
} else if (column.fieldname == "in_qty" && data && data.in_qty > 0) {
111+
value = "<span style='color:green'>" + value + "</span>";
112+
}
113+
114+
return value;
115+
},
116+
};
117+
118+
erpnext.utils.add_inventory_dimensions("Balance Serial No", 10);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"add_total_row": 0,
3+
"apply_user_permissions": 1,
4+
"creation": "2025-03-07 10:54:09.429215",
5+
"disabled": 0,
6+
"docstatus": 0,
7+
"doctype": "Report",
8+
"idx": 0,
9+
"is_standard": "Yes",
10+
"modified": "2025-03-07 10:54:09.429215",
11+
"modified_by": "Administrator",
12+
"module": "Stock",
13+
"name": "Available Serial No",
14+
"owner": "Administrator",
15+
"prepared_report": 0,
16+
"ref_doctype": "Stock Ledger Entry",
17+
"report_name": "Available Serial No",
18+
"report_type": "Script Report",
19+
"roles": [
20+
{
21+
"role": "Stock User"
22+
},
23+
{
24+
"role": "Accounts Manager"
25+
}
26+
],
27+
"timeout": 0
28+
}

0 commit comments

Comments
 (0)