Show Close button in Delivery Note and Purchase Receipt, only if it is returned and user has submit permission
This commit is contained in:
parent
59ba9e3d56
commit
95d025f9aa
@ -46,13 +46,14 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
if (cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
|
||||
this.show_general_ledger();
|
||||
}
|
||||
|
||||
if(doc.status !== "Closed") {
|
||||
cur_frm.add_custom_button(__("Close"), this.close_delivery_note)
|
||||
if (this.frm.has_perm("submit") && (doc.status !== "Closed")
|
||||
&& this.frm.doc.__onload && this.frm.doc.__onload.has_return_entry) {
|
||||
cur_frm.add_custom_button(__("Close"), this.close_delivery_note)
|
||||
}
|
||||
}
|
||||
|
||||
if(doc.__onload && !doc.__onload.billing_complete && doc.docstatus==1 && !doc.is_return && doc.status!="Closed") {
|
||||
if(doc.__onload && !doc.__onload.billing_complete && doc.docstatus==1
|
||||
&& !doc.is_return && doc.status!="Closed") {
|
||||
// show Make Invoice button only if Delivery Note is not created from Sales Invoice
|
||||
var from_sales_invoice = false;
|
||||
from_sales_invoice = cur_frm.doc.items.some(function(item) {
|
||||
@ -63,7 +64,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
|
||||
cur_frm.add_custom_button(__('Invoice'), this.make_sales_invoice).addClass("btn-primary");
|
||||
}
|
||||
|
||||
if(doc.docstatus==1 && doc.status === "Closed") {
|
||||
if(doc.docstatus==1 && doc.status === "Closed" && this.frm.has_perm("submit")) {
|
||||
cur_frm.add_custom_button(__('Re-open'), this.reopen_delivery_note)
|
||||
}
|
||||
erpnext.stock.delivery_note.set_print_hide(doc, dt, dn);
|
||||
|
@ -69,7 +69,10 @@ class DeliveryNote(SellingController):
|
||||
where docstatus=1 and delivery_note=%s""", self.name)
|
||||
if billed_qty:
|
||||
total_qty = sum((item.qty for item in self.get("items")))
|
||||
self.get("__onload").billing_complete = (billed_qty[0][0] == total_qty)
|
||||
self.set_onload("billing_complete", (billed_qty[0][0] == total_qty))
|
||||
|
||||
self.set_onload("has_return_entry", len(frappe.db.exists({"doctype": "Delivery Note",
|
||||
"is_return": 1, "return_against": self.name, "docstatus": 1})))
|
||||
|
||||
def before_print(self):
|
||||
def toggle_print_hide(meta, fieldname):
|
||||
|
@ -57,14 +57,18 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
|
||||
if(this.frm.doc.docstatus == 1 && this.frm.doc.status!="Closed") {
|
||||
cur_frm.add_custom_button(__('Return'), this.make_purchase_return);
|
||||
if(this.frm.doc.__onload && !this.frm.doc.__onload.billing_complete) {
|
||||
cur_frm.add_custom_button(__('Invoice'), this.make_purchase_invoice).addClass("btn-primary");
|
||||
cur_frm.add_custom_button(__('Invoice'),
|
||||
this.make_purchase_invoice).addClass("btn-primary");
|
||||
}
|
||||
if (this.frm.has_perm("submit") &&
|
||||
this.frm.doc.__onload && this.frm.doc.__onload.has_return_entry) {
|
||||
cur_frm.add_custom_button(__("Close"), this.close_purchase_receipt)
|
||||
}
|
||||
cur_frm.add_custom_button(__("Close"), this.close_purchase_receipt)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(this.frm.doc.docstatus==1 && this.frm.doc.status === "Closed") {
|
||||
if(this.frm.doc.docstatus==1 && this.frm.doc.status === "Closed" && this.frm.has_perm("submit")) {
|
||||
cur_frm.add_custom_button(__('Re-open'), this.reopen_purchase_receipt)
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,10 @@ class PurchaseReceipt(BuyingController):
|
||||
where purchase_receipt=%s and docstatus=1""", self.name)
|
||||
if billed_qty:
|
||||
total_qty = sum((item.qty for item in self.get("items")))
|
||||
self.get("__onload").billing_complete = (billed_qty[0][0] == total_qty)
|
||||
self.set_onload("billing_complete", (billed_qty[0][0] == total_qty))
|
||||
|
||||
self.set_onload("has_return_entry", len(frappe.db.exists({"doctype": "Purchase Receipt",
|
||||
"is_return": 1, "return_against": self.name, "docstatus": 1})))
|
||||
|
||||
def validate(self):
|
||||
super(PurchaseReceipt, self).validate()
|
||||
|
Loading…
Reference in New Issue
Block a user