[cleanup] a better message for insufficient stock
This commit is contained in:
parent
e0686b32f3
commit
538607e6b6
@ -3,7 +3,7 @@
|
||||
|
||||
frappe.provide("erpnext.buying");
|
||||
|
||||
{% include 'erpnext/buying/doctype/purchase_common/purchase_common.js' %};
|
||||
{% include 'buying/doctype/purchase_common/purchase_common.js' %};
|
||||
|
||||
frappe.ui.form.on("Purchase Order", {
|
||||
onload: function(frm) {
|
||||
@ -20,6 +20,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
||||
// this.frm.dashboard.reset();
|
||||
var allow_receipt = false;
|
||||
var is_drop_ship = false;
|
||||
|
||||
for (var i in cur_frm.doc.items) {
|
||||
var item = cur_frm.doc.items[i];
|
||||
if(item.delivered_by_supplier !== 1) {
|
||||
@ -46,7 +47,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
||||
|
||||
if(is_drop_ship && doc.status!="Delivered"){
|
||||
cur_frm.add_custom_button(__('Delivered'),
|
||||
this.delivered_by_supplier, __("Status"));
|
||||
this.delivered_by_supplier, __("Status"));
|
||||
|
||||
cur_frm.page.set_inner_btn_group_as_primary(__("Status"));
|
||||
}
|
||||
@ -60,7 +61,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
||||
}
|
||||
}
|
||||
|
||||
if(doc.docstatus == 1 && !in_list(["Closed", "Completed"], doc.status)) {
|
||||
if(doc.docstatus == 1 && doc.status != "Closed") {
|
||||
if(flt(doc.per_received, 2) < 100 && allow_receipt) {
|
||||
cur_frm.add_custom_button(__('Receive'), this.make_purchase_receipt, __("Make"));
|
||||
|
||||
@ -92,6 +93,15 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
|
||||
});
|
||||
},
|
||||
|
||||
validate: function() {
|
||||
// set default schedule date as today if missing.
|
||||
(this.frm.doc.items || []).forEach(function(d) {
|
||||
if(!d.schedule_date) {
|
||||
d.schedule_date = frappe.datetime.nowdate();
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
make_stock_entry: function() {
|
||||
var items = $.map(cur_frm.doc.items, function(d) { return d.bom ? d.item_code : false; });
|
||||
var me = this;
|
||||
|
@ -334,11 +334,23 @@ class update_entries_after(object):
|
||||
|
||||
def raise_exceptions(self):
|
||||
deficiency = min(e["diff"] for e in self.exceptions)
|
||||
msg = _("Negative Stock Error ({6}) for Item {0} in Warehouse {1} on {2} {3} in {4} {5}").format(self.item_code,
|
||||
self.warehouse, self.exceptions[0]["posting_date"], self.exceptions[0]["posting_time"],
|
||||
_(self.exceptions[0]["voucher_type"]), self.exceptions[0]["voucher_no"], deficiency)
|
||||
|
||||
|
||||
|
||||
if frappe.local.flags.currently_saving.doctype==self.exceptions[0]["voucher_type"] \
|
||||
and frappe.local.flags.currently_saving.name==self.exceptions[0]["voucher_no"]:
|
||||
msg = _("{0} units of {1} needed in {2} to complete this transaction.").format(
|
||||
abs(deficiency), frappe.get_desk_link('Item', self.item_code),
|
||||
frappe.get_desk_link('Warehouse', self.warehouse))
|
||||
else:
|
||||
msg = _("{0} units of {1} needed in {2} on {3} {4} for {5} to complete this transaction.").format(
|
||||
abs(deficiency), frappe.get_desk_link('Item', self.item_code),
|
||||
frappe.get_desk_link('Warehouse', self.warehouse),
|
||||
self.exceptions[0]["posting_date"], self.exceptions[0]["posting_time"],
|
||||
frappe.get_desk_link(self.exceptions[0]["voucher_type"], self.exceptions[0]["voucher_no"]))
|
||||
|
||||
if self.verbose:
|
||||
frappe.throw(msg, NegativeStockError)
|
||||
frappe.throw(msg, NegativeStockError, title='Insufficent Stock')
|
||||
else:
|
||||
raise NegativeStockError, msg
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user