Skip to content

Commit

Permalink
fix: moved custom_make_buttons to PurchaseOrderController to avoid du…
Browse files Browse the repository at this point in the history
…plication of dropdown options (#22744)
  • Loading branch information
AfshanKhan authored Jul 23, 2020
1 parent 833682b commit 55125fb
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions erpnext/buying/doctype/purchase_order/purchase_order.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ frappe.provide("erpnext.buying");

frappe.ui.form.on("Purchase Order", {
setup: function(frm) {
frm.custom_make_buttons = {
'Purchase Receipt': 'Receipt',
'Purchase Invoice': 'Invoice',
'Stock Entry': 'Material to Supplier',
'Payment Entry': 'Payment'
}

frm.set_query("reserve_warehouse", "supplied_items", function() {
return {
Expand All @@ -36,20 +30,6 @@ frappe.ui.form.on("Purchase Order", {

},

refresh: function(frm) {
if(frm.doc.docstatus === 1 && frm.doc.status !== 'Closed'
&& flt(frm.doc.per_received) < 100 && flt(frm.doc.per_billed) < 100) {
frm.add_custom_button(__('Update Items'), () => {
erpnext.utils.update_child_items({
frm: frm,
child_docname: "items",
child_doctype: "Purchase Order Detail",
cannot_add_row: false,
})
});
}
},

onload: function(frm) {
set_schedule_date(frm);
if (!frm.doc.transaction_date){
Expand All @@ -76,6 +56,18 @@ frappe.ui.form.on("Purchase Order Item", {
});

erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
setup: function() {
this.frm.custom_make_buttons = {
'Purchase Receipt': 'Receipt',
'Purchase Invoice': 'Invoice',
'Stock Entry': 'Material to Supplier',
'Payment Entry': 'Payment',
}

this._super();

},

refresh: function(doc, cdt, cdn) {
var me = this;
this._super();
Expand All @@ -99,6 +91,16 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(

if(doc.docstatus == 1) {
if(!in_list(["Closed", "Delivered"], doc.status)) {
if(this.frm.doc.status !== 'Closed' && flt(this.frm.doc.per_received) < 100 && flt(this.frm.doc.per_billed) < 100) {
this.frm.add_custom_button(__('Update Items'), () => {
erpnext.utils.update_child_items({
frm: frm,
child_docname: "items",
child_doctype: "Purchase Order Detail",
cannot_add_row: false,
})
});
}
if (this.frm.has_perm("submit")) {
if(flt(doc.per_billed, 6) < 100 || flt(doc.per_received, 6) < 100) {
if (doc.status != "On Hold") {
Expand Down

0 comments on commit 55125fb

Please sign in to comment.