mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-27 02:28:30 +00:00
* fix: bom item query #27890
fix: bom item query
(cherry picked from commit 0a3dd3e954)
# Conflicts:
# erpnext/manufacturing/doctype/bom/test_bom.py
* fix: resolve conflict
* chore: unused imports
[skip ci]
Co-authored-by: Ankush Menat <ankush@iwebnotes.com>
This commit is contained in:
@@ -1135,8 +1135,7 @@ def item_query(doctype, txt, searchfield, start, page_len, filters):
|
||||
query_filters["has_variants"] = 0
|
||||
|
||||
if filters and filters.get("is_stock_item"):
|
||||
or_cond_filters["is_stock_item"] = 1
|
||||
or_cond_filters["has_variants"] = 1
|
||||
query_filters["is_stock_item"] = 1
|
||||
|
||||
return frappe.get_list("Item",
|
||||
fields = fields, filters=query_filters,
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
|
||||
import unittest
|
||||
from collections import deque
|
||||
from functools import partial
|
||||
|
||||
import frappe
|
||||
from frappe.test_runner import make_test_records
|
||||
from frappe.utils import cstr, flt
|
||||
|
||||
from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
|
||||
from erpnext.manufacturing.doctype.bom.bom import item_query
|
||||
from erpnext.manufacturing.doctype.bom_update_tool.bom_update_tool import update_cost
|
||||
from erpnext.stock.doctype.item.test_item import make_item
|
||||
from erpnext.stock.doctype.stock_reconciliation.test_stock_reconciliation import (
|
||||
@@ -344,6 +346,16 @@ class TestBOM(unittest.TestCase):
|
||||
for reqd_item, created_item in zip(reqd_order, created_order):
|
||||
self.assertEqual(reqd_item, created_item.item_code)
|
||||
|
||||
def test_bom_item_query(self):
|
||||
query = partial(item_query, doctype="Item", txt="", searchfield="name", start=0, page_len=20, filters={"is_stock_item": 1})
|
||||
|
||||
test_items = query(txt="_Test")
|
||||
filtered = query(txt="_Test Item 2")
|
||||
|
||||
self.assertNotEqual(len(test_items), len(filtered), msg="Item filtering showing excessive results")
|
||||
self.assertTrue(0 < len(filtered) <= 3, msg="Item filtering showing excessive results")
|
||||
|
||||
|
||||
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})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user