[fix] Don't show Receive for a Purchase Order having non-stock items, show Close button only for users with Submit rights

This commit is contained in:
Anand Doshi 2015-11-12 18:39:57 +05:30
parent 6303f84d45
commit cea5479f4d
3 changed files with 24 additions and 13 deletions

View File

@ -21,11 +21,13 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
if(doc.docstatus == 1 && !in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) {
cur_frm.add_custom_button(__('Stop'), this.stop_purchase_order);
}
if (this.frm.has_perm("submit")) {
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) {
cur_frm.add_custom_button(__('Stop'), this.stop_purchase_order);
}
cur_frm.add_custom_button(__('Close'), this.close_purchase_order);
cur_frm.add_custom_button(__('Close'), this.close_purchase_order);
}
if(doc.delivered_by_supplier && doc.status!="Delivered"){
cur_frm.add_custom_button(__('Mark as Delivered'), this.delivered_by_supplier);
@ -35,7 +37,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry);
}
if(flt(doc.per_received, 2) < 100) {
if(flt(doc.per_received, 2) < 100 && this.frm.doc.__onload.has_stock_item) {
cur_frm.add_custom_button(__('Receive'), this.make_purchase_receipt).addClass("btn-primary");
if(doc.is_subcontracted==="Yes") {
@ -53,7 +55,9 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
}
if(doc.docstatus == 1 && in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
cur_frm.add_custom_button(__('Re-open'), this.unstop_purchase_order);
if (this.frm.has_perm("submit")) {
cur_frm.add_custom_button(__('Re-open'), this.unstop_purchase_order);
}
}
},

View File

@ -33,6 +33,9 @@ class PurchaseOrder(BuyingController):
'overflow_type': 'order'
}]
def onload(self):
self.set_onload("has_stock_item", len(self.get_stock_items()) > 0)
def validate(self):
super(PurchaseOrder, self).validate()

View File

@ -56,13 +56,15 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry);
}
// stop
if(flt(doc.per_delivered, 2) < 100 || flt(doc.per_billed) < 100) {
cur_frm.add_custom_button(__('Stop'), this.stop_sales_order)
}
if (this.frm.has_perm("submit")) {
// stop
if(flt(doc.per_delivered, 2) < 100 || flt(doc.per_billed) < 100) {
cur_frm.add_custom_button(__('Stop'), this.stop_sales_order)
}
cur_frm.add_custom_button(__('Close'), this.close_sales_order)
cur_frm.add_custom_button(__('Close'), this.close_sales_order)
}
// maintenance
if(flt(doc.per_delivered, 2) < 100 && ["Sales", "Shopping Cart"].indexOf(doc.order_type)===-1) {
@ -82,8 +84,10 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
} else {
// un-stop
cur_frm.add_custom_button(__('Re-open'), cur_frm.cscript['Unstop Sales Order']);
if (this.frm.has_perm("submit")) {
// un-stop
cur_frm.add_custom_button(__('Re-open'), cur_frm.cscript['Unstop Sales Order']);
}
}
}