Browse Source

fix: Unable to search project by project name in Sales Invoice (bp #28648)

(cherry picked from commit 08b7c856b2ee94d1f8ac2c019c556eef4d7dd7da)

Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
develop
mergify[bot] 3 years ago
committed by GitHub
parent
commit
071118fa4e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      erpnext/accounts/doctype/sales_invoice/sales_invoice.js
  2. 14
      erpnext/controllers/queries.py

9
erpnext/accounts/doctype/sales_invoice/sales_invoice.js

@ -516,15 +516,6 @@ cur_frm.fields_dict.write_off_cost_center.get_query = function(doc) {
}
}
// project name
//--------------------------
cur_frm.fields_dict['project'].get_query = function(doc, cdt, cdn) {
return{
query: "erpnext.controllers.queries.get_project_name",
filters: {'customer': doc.customer}
}
}
// Income Account in Details Table
// --------------------------------
cur_frm.set_query("income_account", "items", function(doc) {

14
erpnext/controllers/queries.py

@ -539,6 +539,10 @@ def get_filtered_dimensions(doctype, txt, searchfield, start, page_len, filters)
dimension_filters = get_dimension_filter_map()
dimension_filters = dimension_filters.get((filters.get('dimension'),filters.get('account')))
query_filters = []
or_filters = []
fields = ['name']
searchfields = frappe.get_meta(doctype).get_search_fields()
meta = frappe.get_meta(doctype)
if meta.is_tree:
@ -550,8 +554,9 @@ def get_filtered_dimensions(doctype, txt, searchfield, start, page_len, filters)
if meta.has_field('company'):
query_filters.append(['company', '=', filters.get('company')])
if txt:
query_filters.append([searchfield, 'LIKE', "%%%s%%" % txt])
for field in searchfields:
or_filters.append([field, 'LIKE', "%%%s%%" % txt])
fields.append(field)
if dimension_filters:
if dimension_filters['allow_or_restrict'] == 'Allow':
@ -566,10 +571,9 @@ def get_filtered_dimensions(doctype, txt, searchfield, start, page_len, filters)
query_filters.append(['name', query_selector, dimensions])
output = frappe.get_list(doctype, filters=query_filters)
result = [d.name for d in output]
output = frappe.get_list(doctype, fields=fields, filters=query_filters, or_filters=or_filters, as_list=1)
return [(d,) for d in set(result)]
return [tuple(d) for d in set(output)]
@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs

Loading…
Cancel
Save