mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-18 08:58:43 +00:00
fix(bom): allow zero qty for secondary items (Co-Product, By-Product, Scrap, Additional Finished Good)
Secondary output items in a BOM do not always guarantee output during manufacture. The actual qty is only known when manufacturing completes, so setting zero in the BOM is a valid way to express "output is non-deterministic". Changes: - Remove `reqd: 1` from the qty field in BOM Secondary Item so that 0 is accepted as an explicit value (non_negative constraint is kept, so negative values are still rejected). - Relax validate_secondary_items() in bom.py to only reject qty that is None/missing, not qty that is explicitly 0. - Add a qty event handler in bom.js that shows a blue informational alert when the user sets qty to 0, explaining that the actual output will be recorded at manufacture time. Fixes https://github.com/frappe/erpnext/issues/55401 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1012,6 +1012,19 @@ frappe.ui.form.on("BOM Secondary Item", {
|
||||
item_code(frm, cdt, cdn) {
|
||||
const { item_code } = locals[cdt][cdn];
|
||||
},
|
||||
|
||||
qty(frm, cdt, cdn) {
|
||||
const row = locals[cdt][cdn];
|
||||
if (flt(row.qty) === 0) {
|
||||
frappe.show_alert({
|
||||
message: __(
|
||||
"Row #{0}: Qty is set to zero for {1}. The actual output will be entered at the time of manufacture.",
|
||||
[row.idx, frappe.bold(row.item_code)]
|
||||
),
|
||||
indicator: "blue",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
function trigger_process_loss_qty_prompt(frm, cdt, cdn, item_code) {
|
||||
|
||||
@@ -373,9 +373,9 @@ class BOM(WebsiteGenerator):
|
||||
).format(item.idx, get_link_to_form("Item", item.item_code))
|
||||
)
|
||||
|
||||
if not item.qty:
|
||||
if item.qty is None:
|
||||
frappe.throw(
|
||||
_("Row #{0}: Quantity should be greater than 0 for {1} Item {2}").format(
|
||||
_("Row #{0}: Quantity is required for {1} Item {2}").format(
|
||||
item.idx, item.secondary_item_type, get_link_to_form("Item", item.item_code)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -138,8 +138,7 @@
|
||||
"fieldtype": "Float",
|
||||
"in_list_view": 1,
|
||||
"label": "Qty",
|
||||
"non_negative": 1,
|
||||
"reqd": 1
|
||||
"non_negative": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
|
||||
Reference in New Issue
Block a user