fix: moved custom_make_buttons to PurchaseOrderController to avoid duplication of dropdown options (#22744)
This commit is contained in:
parent
833682b03d
commit
55125fbe4e
@ -7,12 +7,6 @@ frappe.provide("erpnext.buying");
|
|||||||
|
|
||||||
frappe.ui.form.on("Purchase Order", {
|
frappe.ui.form.on("Purchase Order", {
|
||||||
setup: function(frm) {
|
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() {
|
frm.set_query("reserve_warehouse", "supplied_items", function() {
|
||||||
return {
|
return {
|
||||||
@ -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) {
|
onload: function(frm) {
|
||||||
set_schedule_date(frm);
|
set_schedule_date(frm);
|
||||||
if (!frm.doc.transaction_date){
|
if (!frm.doc.transaction_date){
|
||||||
@ -76,6 +56,18 @@ frappe.ui.form.on("Purchase Order Item", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({
|
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) {
|
refresh: function(doc, cdt, cdn) {
|
||||||
var me = this;
|
var me = this;
|
||||||
this._super();
|
this._super();
|
||||||
@ -99,6 +91,16 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
|||||||
|
|
||||||
if(doc.docstatus == 1) {
|
if(doc.docstatus == 1) {
|
||||||
if(!in_list(["Closed", "Delivered"], doc.status)) {
|
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 (this.frm.has_perm("submit")) {
|
||||||
if(flt(doc.per_billed, 6) < 100 || flt(doc.per_received, 6) < 100) {
|
if(flt(doc.per_billed, 6) < 100 || flt(doc.per_received, 6) < 100) {
|
||||||
if (doc.status != "On Hold") {
|
if (doc.status != "On Hold") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user