Merge branch 'fix_asset_sold_status' of https://github.com/AnandBaburajan/erpnext into fix_asset_sold_status
This commit is contained in:
commit
eadcd8e614
@ -212,21 +212,15 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
||||
meta = frappe.get_meta(doctype, cached=True)
|
||||
searchfields = meta.get_search_fields()
|
||||
|
||||
# these are handled separately
|
||||
ignored_search_fields = ("item_name", "description")
|
||||
for ignored_field in ignored_search_fields:
|
||||
if ignored_field in searchfields:
|
||||
searchfields.remove(ignored_field)
|
||||
|
||||
columns = ""
|
||||
extra_searchfields = [
|
||||
field
|
||||
for field in searchfields
|
||||
if not field in ["name", "item_group", "description", "item_name"]
|
||||
]
|
||||
extra_searchfields = [field for field in searchfields if not field in ["name", "description"]]
|
||||
|
||||
if extra_searchfields:
|
||||
columns = ", " + ", ".join(extra_searchfields)
|
||||
columns += ", " + ", ".join(extra_searchfields)
|
||||
|
||||
if "description" in searchfields:
|
||||
columns += """, if(length(tabItem.description) > 40, \
|
||||
concat(substr(tabItem.description, 1, 40), "..."), description) as description"""
|
||||
|
||||
searchfields = searchfields + [
|
||||
field
|
||||
@ -266,12 +260,10 @@ def item_query(doctype, txt, searchfield, start, page_len, filters, as_dict=Fals
|
||||
if frappe.db.count(doctype, cache=True) < 50000:
|
||||
# scan description only if items are less than 50000
|
||||
description_cond = "or tabItem.description LIKE %(txt)s"
|
||||
|
||||
return frappe.db.sql(
|
||||
"""select
|
||||
tabItem.name, tabItem.item_name, tabItem.item_group,
|
||||
if(length(tabItem.description) > 40, \
|
||||
concat(substr(tabItem.description, 1, 40), "..."), description) as description
|
||||
{columns}
|
||||
tabItem.name {columns}
|
||||
from tabItem
|
||||
where tabItem.docstatus < 2
|
||||
and tabItem.disabled=0
|
||||
|
@ -5,6 +5,7 @@
|
||||
import json
|
||||
|
||||
import frappe
|
||||
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
|
||||
from frappe.test_runner import make_test_objects
|
||||
from frappe.tests.utils import FrappeTestCase, change_settings
|
||||
from frappe.utils import add_days, today
|
||||
@ -816,6 +817,30 @@ class TestItem(FrappeTestCase):
|
||||
item.reload()
|
||||
self.assertEqual(item.is_stock_item, 1)
|
||||
|
||||
def test_serach_fields_for_item(self):
|
||||
from erpnext.controllers.queries import item_query
|
||||
|
||||
make_property_setter("Item", None, "search_fields", "item_name", "Data", for_doctype="Doctype")
|
||||
|
||||
item = make_item(properties={"item_name": "Test Item", "description": "Test Description"})
|
||||
data = item_query(
|
||||
"Item", "Test Item", "", 0, 20, filters={"item_name": "Test Item"}, as_dict=True
|
||||
)
|
||||
self.assertEqual(data[0].name, item.name)
|
||||
self.assertEqual(data[0].item_name, item.item_name)
|
||||
self.assertTrue("description" not in data[0])
|
||||
|
||||
make_property_setter(
|
||||
"Item", None, "search_fields", "item_name, description", "Data", for_doctype="Doctype"
|
||||
)
|
||||
data = item_query(
|
||||
"Item", "Test Item", "", 0, 20, filters={"item_name": "Test Item"}, as_dict=True
|
||||
)
|
||||
self.assertEqual(data[0].name, item.name)
|
||||
self.assertEqual(data[0].item_name, item.item_name)
|
||||
self.assertEqual(data[0].description, item.description)
|
||||
self.assertTrue("description" in data[0])
|
||||
|
||||
|
||||
def set_item_variant_settings(fields):
|
||||
doc = frappe.get_doc("Item Variant Settings")
|
||||
|
@ -18,7 +18,7 @@
|
||||
<b class="caret"></b>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-right" role="menu">
|
||||
{% if doc.doctype == 'Purchase Order' %}
|
||||
{% if doc.doctype == 'Purchase Order' and show_make_pi_button %}
|
||||
<a class="dropdown-item" href="/api/method/erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice_from_portal?purchase_order_name={{ doc.name }}" data-action="make_purchase_invoice">{{ _("Make Purchase Invoice") }}</a>
|
||||
{% endif %}
|
||||
<a class="dropdown-item" href='/printview?doctype={{ doc.doctype}}&name={{ doc.name }}&format={{ print_format }}'
|
||||
|
@ -52,6 +52,9 @@ def get_context(context):
|
||||
)
|
||||
context.available_loyalty_points = int(loyalty_program_details.get("loyalty_points"))
|
||||
|
||||
# show Make Purchase Invoice button based on permission
|
||||
context.show_make_pi_button = frappe.has_permission("Purchase Invoice", "create")
|
||||
|
||||
|
||||
def get_attachments(dt, dn):
|
||||
return frappe.get_all(
|
||||
|
Loading…
x
Reference in New Issue
Block a user