fix: MR Default Supplier search query
(cherry picked from commit c0a1f298a1)
Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
This commit is contained in:
@@ -550,17 +550,28 @@ def get_default_supplier_query(doctype, txt, searchfield, start, page_len, filte
|
|||||||
for d in doc.items:
|
for d in doc.items:
|
||||||
item_list.append(d.item_code)
|
item_list.append(d.item_code)
|
||||||
|
|
||||||
return frappe.db.sql(
|
supplier = frappe.qb.DocType("Supplier")
|
||||||
"""select default_supplier
|
item_default = frappe.qb.DocType("Item Default")
|
||||||
from `tabItem Default`
|
query = (
|
||||||
where parent in ({0}) and
|
frappe.qb.from_(supplier)
|
||||||
default_supplier IS NOT NULL
|
.left_join(item_default)
|
||||||
""".format(
|
.on(supplier.name == item_default.default_supplier)
|
||||||
", ".join(["%s"] * len(item_list))
|
.select(item_default.default_supplier)
|
||||||
),
|
.where(
|
||||||
tuple(item_list),
|
(item_default.parent.isin(item_list))
|
||||||
|
& (item_default.default_supplier.notnull())
|
||||||
|
& (supplier[searchfield].like(f"%{txt}%"))
|
||||||
|
)
|
||||||
|
.offset(start)
|
||||||
|
.limit(page_len)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
meta = frappe.get_meta("Supplier")
|
||||||
|
if meta.show_title_field_in_link and meta.title_field:
|
||||||
|
query = query.select(supplier[meta.title_field])
|
||||||
|
|
||||||
|
return query.run(as_dict=False)
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_supplier_quotation(source_name, target_doc=None):
|
def make_supplier_quotation(source_name, target_doc=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user