fix: merge conflicts
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index d661bcb..76eb56f 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -19,6 +19,7 @@
from erpnext.exceptions import InvalidCurrency
from six import text_type
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions
+from erpnext.stock.get_item_details import get_item_warehouse
force_item_fields = ("item_group", "brand", "stock_uom", "is_fixed_asset", "item_tax_rate", "pricing_rules")
@@ -1126,16 +1127,16 @@
"""
Returns a Sales Order Item child item containing the default values
"""
- p_doctype = frappe.get_doc(parent_doctype, parent_doctype_name)
- child_item = frappe.new_doc('Sales Order Item', p_doctype, child_docname)
+ p_doc = frappe.get_doc(parent_doctype, parent_doctype_name)
+ child_item = frappe.new_doc('Sales Order Item', p_doc, child_docname)
item = frappe.get_doc("Item", item_code)
child_item.item_code = item.item_code
child_item.item_name = item.item_name
child_item.description = item.description
- child_item.reqd_by_date = p_doctype.delivery_date
+ child_item.reqd_by_date = p_doc.delivery_date
child_item.uom = item.stock_uom
child_item.conversion_factor = get_conversion_factor(item_code, item.stock_uom).get("conversion_factor") or 1.0
- child_item.warehouse = p_doctype.set_warehouse or p_doctype.items[0].warehouse
+ child_item.warehouse = get_item_warehouse(item, p_doc, overwrite_warehouse=True)
return child_item
@@ -1143,13 +1144,13 @@
"""
Returns a Purchase Order Item child item containing the default values
"""
- p_doctype = frappe.get_doc(parent_doctype, parent_doctype_name)
- child_item = frappe.new_doc('Purchase Order Item', p_doctype, child_docname)
+ p_doc = frappe.get_doc(parent_doctype, parent_doctype_name)
+ child_item = frappe.new_doc('Purchase Order Item', p_doc, child_docname)
item = frappe.get_doc("Item", item_code)
child_item.item_code = item.item_code
child_item.item_name = item.item_name
child_item.description = item.description
- child_item.schedule_date = p_doctype.schedule_date
+ child_item.schedule_date = p_doc.schedule_date
child_item.uom = item.stock_uom
child_item.conversion_factor = get_conversion_factor(item_code, item.stock_uom).get("conversion_factor") or 1.0
child_item.base_rate = 1 # Initiallize value will update in parent validation
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 163ef72..c14bb66 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -179,6 +179,12 @@
# scan description only if items are less than 50000
description_cond = 'or tabItem.description LIKE %(txt)s'
+ extra_cond = " and tabItem.has_variants=0"
+ if (filters and isinstance(filters, dict)
+ and filters.get("doctype") == "BOM"):
+ extra_cond = ""
+ del filters["doctype"]
+
return frappe.db.sql("""select tabItem.name,
if(length(tabItem.item_name) > 40,
concat(substr(tabItem.item_name, 1, 40), "..."), item_name) as item_name,
@@ -188,11 +194,11 @@
{columns}
from tabItem
where tabItem.docstatus < 2
- and tabItem.has_variants=0
and tabItem.disabled=0
and (tabItem.end_of_life > %(today)s or ifnull(tabItem.end_of_life, '0000-00-00')='0000-00-00')
and ({scond} or tabItem.item_code IN (select parent from `tabItem Barcode` where barcode LIKE %(txt)s)
{description_cond})
+ {extra_cond}
{fcond} {mcond}
order by
if(locate(%(_txt)s, name), locate(%(_txt)s, name), 99999),
@@ -203,6 +209,7 @@
key=searchfield,
columns=columns,
scond=searchfields,
+ extra_cond=extra_cond,
fcond=get_filters_cond(doctype, filters, conditions).replace('%', '%%'),
mcond=get_match_cond(doctype).replace('%', '%%'),
description_cond = description_cond),