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

This commit is contained in:
rohitwaghchaure
2024-12-05 15:29:34 +05:30
committed by GitHub
parent 7249cf0001
commit 024c442087
2 changed files with 14 additions and 10 deletions

View File

@@ -115,6 +115,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) {
@@ -157,14 +165,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"),

View File

@@ -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
@@ -430,7 +432,9 @@ def make_purchase_order(source_name, target_doc=None, args=None):
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",