Skip to content

Commit

Permalink
fix: PermissionError in Work Order
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Apr 20, 2023
1 parent eaa5f1f commit 8108b2d
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 @@ -625,20 +625,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 8108b2d

Please sign in to comment.