fix: Applied query on PO Supplier popup field in Material Request. (#20231)
This commit is contained in:
parent
4e6b3ada0f
commit
9f6c95549a
@ -230,8 +230,19 @@ frappe.ui.form.on('Material Request', {
|
|||||||
|
|
||||||
make_purchase_order: function(frm) {
|
make_purchase_order: function(frm) {
|
||||||
frappe.prompt(
|
frappe.prompt(
|
||||||
{fieldname:'default_supplier', label: __('For Default Supplier (optional)'), description: __('Selected Supplier\
|
{
|
||||||
must be the Default Supplier of one of the items below.'), fieldtype: 'Link', options: 'Supplier'},
|
label: __('For Default Supplier (Optional)'),
|
||||||
|
fieldname:'default_supplier',
|
||||||
|
fieldtype: 'Link',
|
||||||
|
options: 'Supplier',
|
||||||
|
description: __('Select a Supplier from the Default Supplier List of the items below.'),
|
||||||
|
get_query: () => {
|
||||||
|
return{
|
||||||
|
query: "erpnext.stock.doctype.material_request.material_request.get_default_supplier_query",
|
||||||
|
filters: {'doc': frm.doc.name}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
(values) => {
|
(values) => {
|
||||||
frappe.model.open_mapped_doc({
|
frappe.model.open_mapped_doc({
|
||||||
method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order",
|
method: "erpnext.stock.doctype.material_request.material_request.make_purchase_order",
|
||||||
|
@ -386,6 +386,18 @@ def get_material_requests_based_on_supplier(supplier):
|
|||||||
|
|
||||||
return material_requests, supplier_items
|
return material_requests, supplier_items
|
||||||
|
|
||||||
|
def get_default_supplier_query(doctype, txt, searchfield, start, page_len, filters):
|
||||||
|
doc = frappe.get_doc("Material Request", filters.get("doc"))
|
||||||
|
item_list = []
|
||||||
|
for d in doc.items:
|
||||||
|
item_list.append(d.item_code)
|
||||||
|
|
||||||
|
return frappe.db.sql("""select default_supplier
|
||||||
|
from `tabItem Default`
|
||||||
|
where parent in ({0}) and
|
||||||
|
default_supplier IS NOT NULL
|
||||||
|
""".format(', '.join(['%s']*len(item_list))),tuple(item_list))
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def make_supplier_quotation(source_name, target_doc=None):
|
def make_supplier_quotation(source_name, target_doc=None):
|
||||||
def postprocess(source, target_doc):
|
def postprocess(source, target_doc):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user