Skip to content

Commit

Permalink
Merge pull request #41099 from rohitwaghchaure/fixed-report-13659
Browse files Browse the repository at this point in the history
fix: not able to update default supplier from Supplier Quotation Comparison report
  • Loading branch information
rohitwaghchaure authored Apr 20, 2024
2 parents 29153ed + ad8e189 commit 41035cc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
return row.supplier_name;
});

let items = [];
report.data.forEach((d) => {
if (!items.includes(d.item_code)) {
items.push(d.item_code);
}
});

// Create a dialog window for the user to pick their supplier
let dialog = new frappe.ui.Dialog({
title: __("Select Default Supplier"),
Expand All @@ -151,20 +158,34 @@ frappe.query_reports["Supplier Quotation Comparison"] = {
};
},
},
{
reqd: 1,
label: "Item",
fieldtype: "Link",
options: "Item",
fieldname: "item_code",
get_query: () => {
return {
filters: {
name: ["in", items],
},
};
},
},
],
});

dialog.set_primary_action(__("Set Default Supplier"), () => {
let values = dialog.get_values();

if (values) {
// Set the default_supplier field of the appropriate Item to the selected supplier
frappe.call({
method: "frappe.client.set_value",
method: "erpnext.buying.report.supplier_quotation_comparison.supplier_quotation_comparison.set_default_supplier",
args: {
doctype: "Item",
name: item_code,
fieldname: "default_supplier",
value: values.supplier,
item_code: values.item_code,
supplier: values.supplier,
company: filters.company,
},
freeze: true,
callback: (r) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,13 @@ def get_message():
<span class="indicator red">
Expires today / Already Expired
</span>"""


@frappe.whitelist()
def set_default_supplier(item_code, supplier, company):
frappe.db.set_value(
"Item Default",
{"parent": item_code, "company": company},
"default_supplier",
supplier,
)

0 comments on commit 41035cc

Please sign in to comment.