[enhance] close purchase order

This commit is contained in:
Saurabh 2015-10-19 15:16:17 +05:30
parent c6dbe70256
commit 98b287565a
6 changed files with 36 additions and 19 deletions

View File

@ -19,11 +19,13 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
this._super();
// this.frm.dashboard.reset();
if(doc.docstatus == 1 && doc.status != 'Stopped') {
if(doc.docstatus == 1 && doc.status != 'Stopped' && doc.status != 'Closed') {
if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100)
cur_frm.add_custom_button(__('Stop'), cur_frm.cscript['Stop Purchase Order']);
cur_frm.add_custom_button(__('Close'), cur_frm.cscript['Close Purchase Order']);
if(flt(doc.per_billed)==0) {
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry);
}
@ -223,6 +225,18 @@ cur_frm.cscript['Unstop Purchase Order'] = function() {
}
}
cur_frm.cscript['Close Purchase Order'] = function() {
var doc = cur_frm.doc;
var check = confirm(__("Do you really want to Close ") + doc.name);
if (check) {
return $c('runserverobj', args={'method':'update_status', 'arg': 'Closed', 'docs':doc}, function(r,rt) {
cur_frm.refresh();
});
}
}
cur_frm.pformat.indent_no = function(doc, cdt, cdn){
//function to make row of table

View File

@ -1684,7 +1684,7 @@
"no_copy": 1,
"oldfieldname": "status",
"oldfieldtype": "Select",
"options": "\nDraft\nTo Receive and Bill\nTo Bill\nTo Receive\nCompleted\nStopped\nCancelled",
"options": "\nDraft\nTo Receive and Bill\nTo Bill\nTo Receive\nCompleted\nStopped\nCancelled\nClosed",
"permlevel": 0,
"print_hide": 1,
"read_only": 1,
@ -2238,7 +2238,7 @@
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"modified": "2015-10-16 06:13:50.058318",
"modified": "2015-10-19 14:23:14.190768",
"modified_by": "Administrator",
"module": "Buying",
"name": "Purchase Order",

View File

@ -4,6 +4,8 @@ frappe.listview_settings['Purchase Order'] = {
get_indicator: function(doc) {
if(doc.status==="Stopped") {
return [__("Stopped"), "darkgrey", "status,=,Stopped"];
} else if(doc.status==="Closed"){
return [__("Closed"), "green", "status,=,Closed"];
} else if(flt(doc.per_received, 2) < 100 && doc.status!=="Stopped") {
if(flt(doc.per_billed, 2) < 100) {
return [__("To Receive and Bill"), "orange",

View File

@ -47,6 +47,7 @@ status_map = {
["Completed", "eval:self.per_received == 100 and self.per_billed == 100 and self.docstatus == 1"],
["Stopped", "eval:self.status=='Stopped'"],
["Cancelled", "eval:self.docstatus==2"],
["Closed", "eval:self.status=='Closed'"],
],
"Delivery Note": [
["Draft", None],

View File

@ -236,6 +236,21 @@ cur_frm.cscript['Stop Sales Order'] = function() {
}
}
cur_frm.cscript['Unstop Sales Order'] = function() {
var doc = cur_frm.doc;
var check = confirm(__("Are you sure you want to UNSTOP ") + doc.name);
if (check) {
return $c('runserverobj', {
'method':'unstop_sales_order',
'docs': doc
}, function(r,rt) {
cur_frm.refresh();
});
}
}
cur_frm.cscript['Close Sales Order'] = function(){
var doc = cur_frm.doc;
@ -252,21 +267,6 @@ cur_frm.cscript['Close Sales Order'] = function(){
}
}
cur_frm.cscript['Unstop Sales Order'] = function() {
var doc = cur_frm.doc;
var check = confirm(__("Are you sure you want to UNSTOP ") + doc.name);
if (check) {
return $c('runserverobj', {
'method':'unstop_sales_order',
'docs': doc
}, function(r,rt) {
cur_frm.refresh();
});
}
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
if(cint(frappe.boot.notification_settings.sales_order)) {
cur_frm.email_doc(frappe.boot.notification_settings.sales_order_message);

View File

@ -122,7 +122,7 @@ def get_ordered_qty(item_code, warehouse):
from `tabPurchase Order Item` po_item, `tabPurchase Order` po
where po_item.item_code=%s and po_item.warehouse=%s
and po_item.qty > ifnull(po_item.received_qty, 0) and po_item.parent=po.name
and po.status!='Stopped' and po.docstatus=1""", (item_code, warehouse))
and po.status not in ('Stopped', 'Closed') and po.docstatus=1""", (item_code, warehouse))
return flt(ordered_qty[0][0]) if ordered_qty else 0