Skip to content

Commit

Permalink
fix: PermissionError in Work Order
Browse files Browse the repository at this point in the history
(cherry picked from commit 8108b2d)
  • Loading branch information
s-aga-r authored and mergify[bot] committed Apr 20, 2023
1 parent a2d2beb commit 5680045
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions erpnext/manufacturing/doctype/work_order/work_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,20 +592,18 @@ erpnext.work_order = {
// all materials transferred for manufacturing, make this primary
finish_btn.addClass('btn-primary');
}
} else {
frappe.db.get_doc("Manufacturing Settings").then((doc) => {
let allowance_percentage = doc.overproduction_percentage_for_work_order;

if (allowance_percentage > 0) {
let allowed_qty = frm.doc.qty + ((allowance_percentage / 100) * frm.doc.qty);

if ((flt(doc.produced_qty) < allowed_qty)) {
frm.add_custom_button(__('Finish'), function() {
erpnext.work_order.make_se(frm, 'Manufacture');
});
}
} else if (frm.doc.__onload && frm.doc.__onload.overproduction_percentage) {
let allowance_percentage = frm.doc.__onload.overproduction_percentage;

if (allowance_percentage > 0) {
let allowed_qty = frm.doc.qty + ((allowance_percentage / 100) * frm.doc.qty);

if ((flt(doc.produced_qty) < allowed_qty)) {
frm.add_custom_button(__('Finish'), function() {
erpnext.work_order.make_se(frm, 'Manufacture');
});
}
});
}
}
}
} else {
Expand Down

0 comments on commit 5680045

Please sign in to comment.