[Enhancement] Allow Sidebar Menu record search using text from Item Name of a record (#10324)
* Search Record in Sidebar Menu Using Item Name for Order Page * Test Case to create 2 Quotations with different Items
This commit is contained in:
parent
53f0f62f1c
commit
96e52be5f1
@ -18,8 +18,8 @@ def get_list_context(context=None):
|
|||||||
"get_list": get_transaction_list
|
"get_list": get_transaction_list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_transaction_list(doctype, txt=None, filters=None, limit_start=0, limit_page_length=20, order_by="modified"):
|
def get_transaction_list(doctype, txt=None, filters=None, limit_start=0, limit_page_length=20, order_by="modified"):
|
||||||
from frappe.www.list import get_list
|
|
||||||
user = frappe.session.user
|
user = frappe.session.user
|
||||||
key = None
|
key = None
|
||||||
|
|
||||||
@ -45,16 +45,41 @@ def get_transaction_list(doctype, txt=None, filters=None, limit_start=0, limit_p
|
|||||||
filters.append((doctype, key, "in", parties))
|
filters.append((doctype, key, "in", parties))
|
||||||
|
|
||||||
if key:
|
if key:
|
||||||
return post_process(doctype, get_list(doctype, txt,
|
return post_process(doctype, get_list_for_transactions(doctype, txt,
|
||||||
filters=filters, fields = "name",
|
filters=filters, fields="name",limit_start=limit_start,
|
||||||
limit_start=limit_start, limit_page_length=limit_page_length,
|
limit_page_length=limit_page_length,ignore_permissions=True,
|
||||||
ignore_permissions=True,
|
order_by="modified desc"))
|
||||||
order_by = "modified desc"))
|
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return post_process(doctype, get_list(doctype, txt, filters, limit_start, limit_page_length,
|
return post_process(doctype, get_list_for_transactions(doctype, txt, filters, limit_start, limit_page_length,
|
||||||
fields="name", order_by = "modified desc"))
|
fields="name", order_by="modified desc"))
|
||||||
|
|
||||||
|
def get_list_for_transactions(doctype, txt, filters, limit_start, limit_page_length=20, ignore_permissions=False,fields=None, order_by=None):
|
||||||
|
from frappe.www.list import get_list
|
||||||
|
meta = frappe.get_meta(doctype)
|
||||||
|
data = []
|
||||||
|
or_filters = []
|
||||||
|
|
||||||
|
for d in get_list(doctype, txt, filters=filters, fields="name", limit_start=limit_start,
|
||||||
|
limit_page_length=limit_page_length, ignore_permissions=True, order_by="modified desc"):
|
||||||
|
data.append(d)
|
||||||
|
|
||||||
|
if txt:
|
||||||
|
if meta.get_field('items'):
|
||||||
|
if meta.get_field('items').options:
|
||||||
|
child_doctype = meta.get_field('items').options
|
||||||
|
for item in frappe.get_all(child_doctype, {"item_name": ['like', "%" + txt + "%"]}):
|
||||||
|
child = frappe.get_doc(child_doctype, item.name)
|
||||||
|
or_filters.append([doctype, "name", "=", child.parent])
|
||||||
|
|
||||||
|
if or_filters:
|
||||||
|
for r in frappe.get_list(doctype, fields=fields,filters=filters, or_filters=or_filters, limit_start=limit_start,
|
||||||
|
limit_page_length=limit_page_length, ignore_permissions=ignore_permissions,
|
||||||
|
order_by=order_by):
|
||||||
|
data.append(r)
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
def get_party_details(customers, suppliers):
|
def get_party_details(customers, suppliers):
|
||||||
if customers:
|
if customers:
|
||||||
|
@ -84,6 +84,43 @@ class TestQuotation(unittest.TestCase):
|
|||||||
self.assertEquals(quotation.get("items")[0].rate, rate_with_margin)
|
self.assertEquals(quotation.get("items")[0].rate, rate_with_margin)
|
||||||
si.save()
|
si.save()
|
||||||
|
|
||||||
|
def test_create_two_quotations(self):
|
||||||
|
from erpnext.stock.doctype.item.test_item import make_item
|
||||||
|
|
||||||
|
first_item = make_item("_Test Laptop",
|
||||||
|
{"is_stock_item": 1, "expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||||
|
"cost_center": "_Test Cost Center - _TC"})
|
||||||
|
|
||||||
|
second_item = make_item("_Test CPU",
|
||||||
|
{"is_stock_item": 1, "expense_account": "_Test Account Cost for Goods Sold - _TC",
|
||||||
|
"cost_center": "_Test Cost Center - _TC"})
|
||||||
|
|
||||||
|
qo_item1 = [
|
||||||
|
{
|
||||||
|
"item_code": first_item.item_code,
|
||||||
|
"warehouse": "",
|
||||||
|
"qty": 2,
|
||||||
|
"rate": 400,
|
||||||
|
"delivered_by_supplier": 1,
|
||||||
|
"supplier": '_Test Supplier'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
qo_item2 = [
|
||||||
|
{
|
||||||
|
"item_code": second_item.item_code,
|
||||||
|
"warehouse": "_Test Warehouse - _TC",
|
||||||
|
"qty": 2,
|
||||||
|
"rate": 300,
|
||||||
|
"conversion_factor": 1.0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
first_qo = make_quotation(item_list=qo_item1, do_not_submit=True)
|
||||||
|
first_qo.submit()
|
||||||
|
sec_qo = make_quotation(item_list=qo_item2, do_not_submit=True)
|
||||||
|
sec_qo.submit()
|
||||||
|
|
||||||
test_records = frappe.get_test_records('Quotation')
|
test_records = frappe.get_test_records('Quotation')
|
||||||
|
|
||||||
def get_quotation_dict(customer=None, item_code=None):
|
def get_quotation_dict(customer=None, item_code=None):
|
||||||
@ -103,3 +140,41 @@ def get_quotation_dict(customer=None, item_code=None):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def make_quotation(**args):
|
||||||
|
qo = frappe.new_doc("Quotation")
|
||||||
|
args = frappe._dict(args)
|
||||||
|
if args.transaction_date:
|
||||||
|
qo.transaction_date = args.transaction_date
|
||||||
|
|
||||||
|
qo.company = args.company or "_Test Company"
|
||||||
|
qo.customer = args.customer or "_Test Customer"
|
||||||
|
qo.currency = args.currency or "INR"
|
||||||
|
if args.selling_price_list:
|
||||||
|
qo.selling_price_list = args.selling_price_list
|
||||||
|
|
||||||
|
if "warehouse" not in args:
|
||||||
|
args.warehouse = "_Test Warehouse - _TC"
|
||||||
|
|
||||||
|
if args.item_list:
|
||||||
|
for item in args.item_list:
|
||||||
|
qo.append("items", item)
|
||||||
|
|
||||||
|
else:
|
||||||
|
qo.append("items", {
|
||||||
|
"item_code": args.item or args.item_code or "_Test Item",
|
||||||
|
"warehouse": args.warehouse,
|
||||||
|
"qty": args.qty or 10,
|
||||||
|
"uom": args.uom or None,
|
||||||
|
"rate": args.rate or 100
|
||||||
|
})
|
||||||
|
|
||||||
|
qo.delivery_date = add_days(qo.transaction_date, 10)
|
||||||
|
|
||||||
|
if not args.do_not_save:
|
||||||
|
qo.insert()
|
||||||
|
if not args.do_not_submit:
|
||||||
|
qo.submit()
|
||||||
|
|
||||||
|
return qo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user