Skip to content

Commit

Permalink
fix: not able to make PO for returned qty from material request (back…
Browse files Browse the repository at this point in the history
…port #44540) (#44547)

fix: not able to make PO for returned qty from material request (#44540)

(cherry picked from commit 024c442)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
  • Loading branch information
mergify[bot] and rohitwaghchaure authored Dec 5, 2024
1 parent 99a3271 commit 5ef063c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
16 changes: 8 additions & 8 deletions erpnext/stock/doctype/material_request/material_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ frappe.ui.form.on("Material Request", {

if (flt(frm.doc.per_received, precision) < 100) {
frm.add_custom_button(__("Stop"), () => frm.events.update_status(frm, "Stopped"));

if (frm.doc.material_request_type === "Purchase") {
frm.add_custom_button(
__("Purchase Order"),
() => frm.events.make_purchase_order(frm),
__("Create")
);
}
}

if (flt(frm.doc.per_ordered, precision) < 100) {
Expand Down Expand Up @@ -149,14 +157,6 @@ frappe.ui.form.on("Material Request", {
);
}

if (frm.doc.material_request_type === "Purchase") {
frm.add_custom_button(
__("Purchase Order"),
() => frm.events.make_purchase_order(frm),
__("Create")
);
}

if (frm.doc.material_request_type === "Purchase") {
frm.add_custom_button(
__("Request for Quotation"),
Expand Down
8 changes: 6 additions & 2 deletions erpnext/stock/doctype/material_request/material_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ def set_missing_values(source, target_doc):

def update_item(obj, target, source_parent):
target.conversion_factor = obj.conversion_factor
target.qty = flt(flt(obj.stock_qty) - flt(obj.ordered_qty)) / target.conversion_factor

qty = obj.received_qty or obj.ordered_qty
target.qty = flt(flt(obj.stock_qty) - flt(qty)) / target.conversion_factor
target.stock_qty = target.qty * target.conversion_factor
if getdate(target.schedule_date) < getdate(nowdate()):
target.schedule_date = None
Expand Down Expand Up @@ -430,7 +432,9 @@ def select_item(d):
filtered_items = args.get("filtered_children", [])
child_filter = d.name in filtered_items if filtered_items else True

return d.ordered_qty < d.stock_qty and child_filter
qty = d.received_qty or d.ordered_qty

return qty < d.stock_qty and child_filter

doclist = get_mapped_doc(
"Material Request",
Expand Down

0 comments on commit 5ef063c

Please sign in to comment.