fix: non manufacturing items/fixed asset items in BOM
(cherry picked from commit aba8431d70)
This commit is contained in:
committed by
Mergify
parent
7b6a1e5184
commit
8133be4868
@@ -48,7 +48,9 @@ frappe.ui.form.on("BOM", {
|
|||||||
return {
|
return {
|
||||||
query: "erpnext.manufacturing.doctype.bom.bom.item_query",
|
query: "erpnext.manufacturing.doctype.bom.bom.item_query",
|
||||||
filters: {
|
filters: {
|
||||||
"item_code": doc.item
|
"item_code": doc.item,
|
||||||
|
"include_item_in_manufacturing": 1,
|
||||||
|
"is_fixed_asset": 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1339,8 +1339,9 @@ def item_query(doctype, txt, searchfield, start, page_len, filters):
|
|||||||
if not has_variants:
|
if not has_variants:
|
||||||
query_filters["has_variants"] = 0
|
query_filters["has_variants"] = 0
|
||||||
|
|
||||||
if filters and filters.get("is_stock_item"):
|
if filters:
|
||||||
query_filters["is_stock_item"] = 1
|
for fieldname, value in filters.items():
|
||||||
|
query_filters[fieldname] = value
|
||||||
|
|
||||||
return frappe.get_list(
|
return frappe.get_list(
|
||||||
"Item",
|
"Item",
|
||||||
|
|||||||
@@ -698,6 +698,45 @@ class TestBOM(FrappeTestCase):
|
|||||||
bom.update_cost()
|
bom.update_cost()
|
||||||
self.assertFalse(bom.flags.cost_updated)
|
self.assertFalse(bom.flags.cost_updated)
|
||||||
|
|
||||||
|
def test_do_not_include_manufacturing_and_fixed_items(self):
|
||||||
|
from erpnext.manufacturing.doctype.bom.bom import item_query
|
||||||
|
|
||||||
|
if not frappe.db.exists("Asset Category", "Computers-Test"):
|
||||||
|
doc = frappe.get_doc({"doctype": "Asset Category", "asset_category_name": "Computers-Test"})
|
||||||
|
doc.flags.ignore_mandatory = True
|
||||||
|
doc.insert()
|
||||||
|
|
||||||
|
for item_code, properties in {
|
||||||
|
"_Test RM Item 1 Do Not Include In Manufacture": {
|
||||||
|
"is_stock_item": 1,
|
||||||
|
"include_item_in_manufacturing": 0,
|
||||||
|
},
|
||||||
|
"_Test RM Item 2 Fixed Asset Item": {
|
||||||
|
"is_fixed_asset": 1,
|
||||||
|
"is_stock_item": 0,
|
||||||
|
"asset_category": "Computers-Test",
|
||||||
|
},
|
||||||
|
"_Test RM Item 3 Manufacture Item": {"is_stock_item": 1, "include_item_in_manufacturing": 1},
|
||||||
|
}.items():
|
||||||
|
make_item(item_code, properties)
|
||||||
|
|
||||||
|
data = item_query(
|
||||||
|
"Item",
|
||||||
|
txt="_Test RM Item",
|
||||||
|
searchfield="name",
|
||||||
|
start=0,
|
||||||
|
page_len=20000,
|
||||||
|
filters={"include_item_in_manufacturing": 1, "is_fixed_asset": 0},
|
||||||
|
)
|
||||||
|
|
||||||
|
items = []
|
||||||
|
for row in data:
|
||||||
|
items.append(row[0])
|
||||||
|
|
||||||
|
self.assertTrue("_Test RM Item 1 Do Not Include In Manufacture" not in items)
|
||||||
|
self.assertTrue("_Test RM Item 2 Fixed Asset Item" not in items)
|
||||||
|
self.assertTrue("_Test RM Item 3 Manufacture Item" in items)
|
||||||
|
|
||||||
|
|
||||||
def get_default_bom(item_code="_Test FG Item 2"):
|
def get_default_bom(item_code="_Test FG Item 2"):
|
||||||
return frappe.db.get_value("BOM", {"item": item_code, "is_active": 1, "is_default": 1})
|
return frappe.db.get_value("BOM", {"item": item_code, "is_active": 1, "is_default": 1})
|
||||||
|
|||||||
Reference in New Issue
Block a user