Merge pull request #4854 from patilsangram/develop

Removed Stop Button from SO and PO
This commit is contained in:
Nabin Hait 2016-02-24 11:21:17 +05:30
commit d2d261dc87
31 changed files with 99 additions and 124 deletions

View File

@ -203,7 +203,7 @@ class JournalEntry(AccountsController):
self.validate_invoices()
def validate_orders(self):
"""Validate totals, stopped and docstatus for orders"""
"""Validate totals, closed and docstatus for orders"""
for reference_name, total in self.reference_totals.iteritems():
reference_type = self.reference_types[reference_name]
account = self.reference_accounts[reference_name]
@ -217,8 +217,8 @@ class JournalEntry(AccountsController):
if flt(order.per_billed) >= 100:
frappe.throw(_("{0} {1} is fully billed").format(reference_type, reference_name))
if cstr(order.status) == "Stopped":
frappe.throw(_("{0} {1} is stopped").format(reference_type, reference_name))
if cstr(order.status) == "Closed":
frappe.throw(_("{0} {1} is closed").format(reference_type, reference_name))
account_currency = get_account_currency(account)
if account_currency == self.company_currency:

View File

@ -133,7 +133,7 @@ def get_orders_to_be_billed(party_type, party, party_account_currency, company_c
where
{party_type} = %s
and docstatus = 1
and ifnull(status, "") != "Stopped"
and ifnull(status, "") != "Closed"
and {ref_field} > advance_paid
and abs(100 - per_billed) > 0.01
""".format(**{

View File

@ -41,7 +41,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
get_query_filters: {
supplier: cur_frm.doc.supplier || undefined,
docstatus: 1,
status: ["not in", ["Stopped", "Closed"]],
status: ["!=", "Closed"],
per_billed: ["<", 99.99],
company: cur_frm.doc.company
}

View File

@ -49,7 +49,7 @@ class PurchaseInvoice(BuyingController):
self.check_conversion_rate()
self.validate_credit_to_acc()
self.clear_unallocated_advances("Purchase Invoice Advance", "advances")
self.check_for_stopped_or_closed_status()
self.check_for_closed_status()
self.validate_with_previous_doc()
self.validate_uom_is_integer("uom", "qty")
self.set_against_expense_account()
@ -104,14 +104,14 @@ class PurchaseInvoice(BuyingController):
self.party_account_currency = account.account_currency
def check_for_stopped_or_closed_status(self):
def check_for_closed_status(self):
check_list = []
pc_obj = frappe.get_doc('Purchase Common')
for d in self.get('items'):
if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt:
check_list.append(d.purchase_order)
pc_obj.check_for_stopped_or_closed_status('Purchase Order', d.purchase_order)
pc_obj.check_for_closed_status('Purchase Order', d.purchase_order)
def validate_with_previous_doc(self):
super(PurchaseInvoice, self).validate_with_previous_doc({
@ -405,7 +405,7 @@ class PurchaseInvoice(BuyingController):
make_gl_entries(gl_entries, cancel=(self.docstatus == 2))
def on_cancel(self):
self.check_for_stopped_or_closed_status()
self.check_for_closed_status()
if not self.is_return:
from erpnext.accounts.utils import remove_against_link_from_jv

View File

@ -116,7 +116,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
source_doctype: "Sales Order",
get_query_filters: {
docstatus: 1,
status: ["not in", ["Stopped", "Closed"]],
status: ["!=", "Closed"],
per_billed: ["<", 99.99],
customer: cur_frm.doc.customer || undefined,
company: cur_frm.doc.company

View File

@ -53,7 +53,7 @@ class SalesInvoice(SellingController):
self.validate_proj_cust()
self.validate_with_previous_doc()
self.validate_uom_is_integer("stock_uom", "qty")
self.check_stop_or_close_sales_order("sales_order")
self.check_close_sales_order("sales_order")
self.validate_debit_to_acc()
self.validate_fixed_asset_account()
self.clear_unallocated_advances("Sales Invoice Advance", "advances")
@ -121,7 +121,7 @@ class SalesInvoice(SellingController):
if cint(self.update_stock) == 1:
self.update_stock_ledger()
self.check_stop_or_close_sales_order("sales_order")
self.check_close_sales_order("sales_order")
from erpnext.accounts.utils import remove_against_link_from_jv
remove_against_link_from_jv(self.doctype, self.name)

View File

@ -7,12 +7,12 @@
"doctype": "Report",
"idx": 1,
"is_standard": "Yes",
"modified": "2015-11-04 11:56:32.699103",
"modified": "2016-02-23 18:48:42.372321",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Ordered Items To Be Billed",
"owner": "Administrator",
"query": "select \n `tabSales Order`.`name` as \"Sales Order:Link/Sales Order:120\",\n `tabSales Order`.`customer` as \"Customer:Link/Customer:120\",\n `tabSales Order`.`status` as \"Status\",\n `tabSales Order`.`transaction_date` as \"Date:Date\",\n `tabSales Order`.`project_name` as \"Project\",\n `tabSales Order Item`.item_code as \"Item:Link/Item:120\",\n `tabSales Order Item`.base_amount as \"Amount:Currency:110\",\n (`tabSales Order Item`.billed_amt * ifnull(`tabSales Order`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabSales Order Item`.base_amount, 0) - (ifnull(`tabSales Order Item`.billed_amt, 0) * ifnull(`tabSales Order`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabSales Order Item`.item_name as \"Item Name::150\",\n `tabSales Order Item`.description as \"Description::200\",\n `tabSales Order`.`company` as \"Company:Link/Company:\"\nfrom\n `tabSales Order`, `tabSales Order Item`\nwhere\n `tabSales Order Item`.`parent` = `tabSales Order`.`name`\n and `tabSales Order`.docstatus = 1\n and `tabSales Order`.status not in (\"Stopped\", \"Closed\")\n and ifnull(`tabSales Order Item`.billed_amt,0) < ifnull(`tabSales Order Item`.amount,0)\norder by `tabSales Order`.transaction_date asc",
"query": "select \n `tabSales Order`.`name` as \"Sales Order:Link/Sales Order:120\",\n `tabSales Order`.`customer` as \"Customer:Link/Customer:120\",\n `tabSales Order`.`status` as \"Status\",\n `tabSales Order`.`transaction_date` as \"Date:Date\",\n `tabSales Order`.`project_name` as \"Project\",\n `tabSales Order Item`.item_code as \"Item:Link/Item:120\",\n `tabSales Order Item`.base_amount as \"Amount:Currency:110\",\n (`tabSales Order Item`.billed_amt * ifnull(`tabSales Order`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabSales Order Item`.base_amount, 0) - (ifnull(`tabSales Order Item`.billed_amt, 0) * ifnull(`tabSales Order`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabSales Order Item`.item_name as \"Item Name::150\",\n `tabSales Order Item`.description as \"Description::200\",\n `tabSales Order`.`company` as \"Company:Link/Company:\"\nfrom\n `tabSales Order`, `tabSales Order Item`\nwhere\n `tabSales Order Item`.`parent` = `tabSales Order`.`name`\n and `tabSales Order`.docstatus = 1\n and `tabSales Order`.status != \"Closed\"\n and ifnull(`tabSales Order Item`.billed_amt,0) < ifnull(`tabSales Order Item`.amount,0)\norder by `tabSales Order`.transaction_date asc",
"ref_doctype": "Sales Invoice",
"report_name": "Ordered Items To Be Billed",
"report_type": "Query Report"

View File

@ -7,12 +7,12 @@
"doctype": "Report",
"idx": 1,
"is_standard": "Yes",
"modified": "2015-11-04 11:56:14.321664",
"modified": "2016-02-23 18:51:21.968327",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Order Items To Be Billed",
"owner": "Administrator",
"query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.base_amount as \"Amount:Currency:100\",\n\t(`tabPurchase Order Item`.billed_amt * ifnull(`tabPurchase Order`.conversion_rate, 1)) as \"Billed Amount:Currency:100\", \n\t(`tabPurchase Order Item`.base_amount - (ifnull(`tabPurchase Order Item`.billed_amt, 0) * ifnull(`tabPurchase Order`.conversion_rate, 1))) as \"Amount to Bill:Currency:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\",\n\t`tabPurchase Order`.company as \"Company:Link/Company:\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status not in (\"Stopped\", \"Closed\")\n\tand (ifnull(`tabPurchase Order Item`.billed_amt, 0) * ifnull(`tabPurchase Order`.conversion_rate, 1)) < ifnull(`tabPurchase Order Item`.base_amount, 0)\norder by `tabPurchase Order`.transaction_date asc",
"query": "select \n `tabPurchase Order`.`name` as \"Purchase Order:Link/Purchase Order:120\",\n `tabPurchase Order`.`transaction_date` as \"Date:Date:100\",\n\t`tabPurchase Order`.`supplier` as \"Supplier:Link/Supplier:120\",\n\t`tabPurchase Order Item`.`project_name` as \"Project\",\n\t`tabPurchase Order Item`.item_code as \"Item Code:Link/Item:120\",\n\t`tabPurchase Order Item`.base_amount as \"Amount:Currency:100\",\n\t(`tabPurchase Order Item`.billed_amt * ifnull(`tabPurchase Order`.conversion_rate, 1)) as \"Billed Amount:Currency:100\", \n\t(`tabPurchase Order Item`.base_amount - (ifnull(`tabPurchase Order Item`.billed_amt, 0) * ifnull(`tabPurchase Order`.conversion_rate, 1))) as \"Amount to Bill:Currency:100\",\n\t`tabPurchase Order Item`.item_name as \"Item Name::150\",\n\t`tabPurchase Order Item`.description as \"Description::200\",\n\t`tabPurchase Order`.company as \"Company:Link/Company:\"\nfrom\n\t`tabPurchase Order`, `tabPurchase Order Item`\nwhere\n\t`tabPurchase Order Item`.`parent` = `tabPurchase Order`.`name`\n\tand `tabPurchase Order`.docstatus = 1\n\tand `tabPurchase Order`.status != \"Closed\"\n\tand (ifnull(`tabPurchase Order Item`.billed_amt, 0) * ifnull(`tabPurchase Order`.conversion_rate, 1)) < ifnull(`tabPurchase Order Item`.base_amount, 0)\norder by `tabPurchase Order`.transaction_date asc",
"ref_doctype": "Purchase Invoice",
"report_name": "Purchase Order Items To Be Billed",
"report_type": "Query Report"

View File

@ -80,10 +80,10 @@ class PurchaseCommon(BuyingController):
frappe.msgprint(_("Warning: Same item has been entered multiple times."))
def check_for_stopped_or_closed_status(self, doctype, docname):
def check_for_closed_status(self, doctype, docname):
status = frappe.db.get_value(doctype, docname, "status")
if status in ("Stopped", "Closed"):
if status == "Closed":
frappe.throw(_("{0} {1} status is {2}").format(doctype, docname, status), frappe.InvalidStatusError)
def check_docstatus(self, check, doctype, docname, detail_doctype = ''):

View File

@ -38,13 +38,13 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
cur_frm.set_df_property("drop_ship", "hidden", !is_drop_ship);
if(doc.docstatus == 1 && !in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
if(doc.docstatus == 1 && !in_list(["Closed", "Delivered"], doc.status)) {
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, __("Status"));
cur_frm.add_custom_button(__('Close'), this.close_purchase_order, __("Status"));
}
cur_frm.add_custom_button(__('Close'), this.close_purchase_order, __("Status"));
}
@ -58,13 +58,13 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
cur_frm.cscript.add_from_mappers();
}
if(doc.docstatus == 1 && in_list(["Stopped", "Closed", "Delivered"], doc.status)) {
if(doc.docstatus == 1 && in_list(["Closed", "Delivered"], doc.status)) {
if (this.frm.has_perm("submit")) {
cur_frm.add_custom_button(__('Re-open'), this.unstop_purchase_order, __("Status"));
cur_frm.add_custom_button(__('Re-open'), this.unclose_purchase_order, __("Status"));
}
}
if(doc.docstatus == 1 && !in_list(["Stopped", "Closed"], 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"));
@ -192,11 +192,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
});
},
stop_purchase_order: function(){
cur_frm.cscript.update_status('Stop', 'Stopped')
},
unstop_purchase_order: function(){
unclose_purchase_order: function(){
cur_frm.cscript.update_status('Re-open', 'Submitted')
},

View File

@ -1907,7 +1907,7 @@
"no_copy": 1,
"oldfieldname": "status",
"oldfieldtype": "Select",
"options": "\nDraft\nTo Receive and Bill\nTo Bill\nTo Receive\nCompleted\nStopped\nCancelled\nClosed\nDelivered",
"options": "\nDraft\nTo Receive and Bill\nTo Bill\nTo Receive\nCompleted\nCancelled\nClosed\nDelivered",
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,

View File

@ -39,7 +39,7 @@ class PurchaseOrder(BuyingController):
self.set_status()
pc_obj = frappe.get_doc('Purchase Common')
pc_obj.validate_for_items(self)
self.check_for_stopped_or_closed_status(pc_obj)
self.check_for_closed_status(pc_obj)
self.validate_uom_is_integer("uom", "qty")
self.validate_uom_is_integer("stock_uom", ["qty", "required_qty"])
@ -113,13 +113,13 @@ class PurchaseOrder(BuyingController):
d.base_price_list_rate = d.base_rate = d.price_list_rate \
= d.rate = item_last_purchase_rate
# Check for Stopped status
def check_for_stopped_or_closed_status(self, pc_obj):
# Check for Closed status
def check_for_closed_status(self, pc_obj):
check_list =[]
for d in self.get('items'):
if d.meta.get_field('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
check_list.append(d.prevdoc_docname)
pc_obj.check_for_stopped_or_closed_status( d.prevdoc_doctype, d.prevdoc_docname)
pc_obj.check_for_closed_status( d.prevdoc_doctype, d.prevdoc_docname)
def update_requested_qty(self):
material_request_map = {}
@ -193,7 +193,7 @@ class PurchaseOrder(BuyingController):
self.update_delivered_qty_in_sales_order()
pc_obj = frappe.get_doc('Purchase Common')
self.check_for_stopped_or_closed_status(pc_obj)
self.check_for_closed_status(pc_obj)
# Check if Purchase Receipt has been submitted against current Purchase Order
pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Receipt', docname = self.name, detail_doctype = 'Purchase Receipt Item')
@ -253,7 +253,7 @@ class PurchaseOrder(BuyingController):
item.received_qty = item.qty
@frappe.whitelist()
def stop_or_unstop_purchase_orders(names, status):
def close_or_unclose_purchase_orders(names, status):
if not frappe.has_permission("Purchase Order", "write"):
frappe.throw(_("Not permitted"), frappe.PermissionError)
@ -261,11 +261,11 @@ def stop_or_unstop_purchase_orders(names, status):
for name in names:
po = frappe.get_doc("Purchase Order", name)
if po.docstatus == 1:
if status in ("Stopped", "Closed"):
if po.status not in ("Stopped", "Cancelled", "Closed") and (po.per_received < 100 or po.per_billed < 100):
if status == "Closed":
if po.status not in ( "Cancelled", "Closed") and (po.per_received < 100 or po.per_billed < 100):
po.update_status(status)
else:
if po.status in ("Stopped", "Closed"):
if po.status == "Closed":
po.update_status("Draft")
frappe.local.message_log = []

View File

@ -2,37 +2,31 @@ frappe.listview_settings['Purchase Order'] = {
add_fields: ["base_grand_total", "company", "currency", "supplier",
"supplier_name", "per_received", "per_billed", "status"],
get_indicator: function(doc) {
if(doc.status==="Stopped") {
return [__("Stopped"), "darkgrey", "status,=,Stopped"];
} else if(doc.status==="Closed"){
if(doc.status==="Closed"){
return [__("Closed"), "green", "status,=,Closed"];
} else if (doc.status==="Delivered") {
return [__("Delivered"), "green", "status,=,Closed"];
}else if(flt(doc.per_received, 2) < 100 && doc.status!=="Stopped") {
}else if(flt(doc.per_received, 2) < 100 && doc.status!=="Closed") {
if(flt(doc.per_billed, 2) < 100) {
return [__("To Receive and Bill"), "orange",
"per_received,<,100|per_billed,<,100|status,!=,Stopped"];
"per_received,<,100|per_billed,<,100|status,!=,Closed"];
} else {
return [__("To Receive"), "orange",
"per_received,<,100|per_billed,=,100|status,!=,Stopped"];
"per_received,<,100|per_billed,=,100|status,!=,Closed"];
}
} else if(flt(doc.per_received, 2) == 100 && flt(doc.per_billed, 2) < 100 && doc.status!=="Stopped") {
return [__("To Bill"), "orange", "per_received,=,100|per_billed,<,100|status,!=,Stopped"];
} else if(flt(doc.per_received, 2) == 100 && flt(doc.per_billed, 2) == 100 && doc.status!=="Stopped") {
return [__("Completed"), "green", "per_received,=,100|per_billed,=,100|status,!=,Stopped"];
} else if(flt(doc.per_received, 2) == 100 && flt(doc.per_billed, 2) < 100 && doc.status!=="Closed") {
return [__("To Bill"), "orange", "per_received,=,100|per_billed,<,100|status,!=,Closed"];
} else if(flt(doc.per_received, 2) == 100 && flt(doc.per_billed, 2) == 100 && doc.status!=="Closed") {
return [__("Completed"), "green", "per_received,=,100|per_billed,=,100|status,!=,Closed"];
}
},
onload: function(listview) {
var method = "erpnext.buying.doctype.purchase_order.purchase_order.stop_or_unstop_purchase_orders";
var method = "erpnext.buying.doctype.purchase_order.purchase_order.close_or_unclose_purchase_orders";
listview.page.add_menu_item(__("Close"), function() {
listview.call_for_selected_items(method, {"status": "Closed"});
});
listview.page.add_menu_item(__("Stop"), function() {
listview.call_for_selected_items(method, {"status": "Stopped"});
});
listview.page.add_menu_item(__("Re-open"), function() {
listview.call_for_selected_items(method, {"status": "Submitted"});
});

View File

@ -34,7 +34,7 @@ def manage_recurring_documents(doctype, next_date=None, commit=True):
date_field = date_field_map[doctype]
condition = " and ifnull(status, '') != 'Stopped'" if doctype in ("Sales Order", "Purchase Order") else ""
condition = " and ifnull(status, '') != 'Closed'" if doctype in ("Sales Order", "Purchase Order") else ""
recurring_documents = frappe.db.sql("""select name, recurring_id
from `tab{0}` where is_recurring=1

View File

@ -219,11 +219,11 @@ class SellingController(StockController):
so_warehouse = so_item and so_item[0]["warehouse"] or ""
return so_qty, so_warehouse
def check_stop_or_close_sales_order(self, ref_fieldname):
def check_close_sales_order(self, ref_fieldname):
for d in self.get("items"):
if d.get(ref_fieldname):
status = frappe.db.get_value("Sales Order", d.get(ref_fieldname), "status")
if status in ("Stopped", "Closed"):
if status == "Closed":
frappe.throw(_("Sales Order {0} is {1}").format(d.get(ref_fieldname), status))
def check_active_sales_items(obj):

View File

@ -35,7 +35,6 @@ status_map = {
["To Deliver", "eval:self.per_delivered < 100 and self.per_billed == 100 and self.docstatus == 1"],
["Completed", "eval:self.per_delivered == 100 and self.per_billed == 100 and self.docstatus == 1"],
["Completed", "eval:self.order_type == 'Maintenance' and self.per_billed == 100 and self.docstatus == 1"],
["Stopped", "eval:self.status=='Stopped'"],
["Cancelled", "eval:self.docstatus==2"],
["Closed", "eval:self.status=='Closed'"],
],
@ -46,7 +45,6 @@ status_map = {
["To Receive", "eval:self.per_received < 100 and self.per_billed == 100 and self.docstatus == 1"],
["Completed", "eval:self.per_received == 100 and self.per_billed == 100 and self.docstatus == 1"],
["Delivered", "eval:self.status=='Delivered'"],
["Stopped", "eval:self.status=='Stopped'"],
["Cancelled", "eval:self.docstatus==2"],
["Closed", "eval:self.status=='Closed'"],
],

View File

@ -243,8 +243,8 @@ class StockController(AccountsController):
if so and so_item_rows:
sales_order = frappe.get_doc("Sales Order", so)
if sales_order.status in ["Stopped", "Cancelled"]:
frappe.throw(_("{0} {1} is cancelled or stopped").format(_("Sales Order"), so),
if sales_order.status in ["Closed", "Cancelled"]:
frappe.throw(_("{0} {1} is cancelled or closed").format(_("Sales Order"), so),
frappe.InvalidStatusError)
sales_order.update_reserved_qty(so_item_rows)

View File

@ -19,7 +19,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
var allow_delivery = false;
if(doc.docstatus==1) {
if(doc.status != 'Stopped' && doc.status != 'Closed') {
if(doc.status != 'Closed') {
for (var i in cur_frm.doc.items) {
var item = cur_frm.doc.items[i];
@ -42,13 +42,10 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
}
if (this.frm.has_perm("submit")) {
// stop
// close
if(flt(doc.per_delivered, 2) < 100 || flt(doc.per_billed) < 100) {
cur_frm.add_custom_button(__('Stop'), this.stop_sales_order, __("Status"))
cur_frm.add_custom_button(__('Close'), this.close_sales_order, __("Status"))
}
cur_frm.add_custom_button(__('Close'), this.close_sales_order, __("Status"))
}
// delivery note
@ -87,8 +84,8 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
} else {
if (this.frm.has_perm("submit")) {
// un-stop
cur_frm.add_custom_button(__('Re-open'), cur_frm.cscript['Unstop Sales Order'], __("Status"));
// un-close
cur_frm.add_custom_button(__('Re-open'), cur_frm.cscript['Unclose Sales Order'], __("Status"));
}
}
}
@ -220,9 +217,6 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
});
dialog.show();
},
stop_sales_order: function(){
cur_frm.cscript.update_status("Stop", "Stopped")
},
close_sales_order: function(){
cur_frm.cscript.update_status("Close", "Closed")
}
@ -263,7 +257,7 @@ cur_frm.cscript.update_status = function(label, status){
});
}
cur_frm.cscript['Unstop Sales Order'] = function() {
cur_frm.cscript['Unclose Sales Order'] = function() {
cur_frm.cscript.update_status('Re-open', 'Draft')
}

View File

@ -2201,7 +2201,7 @@
"no_copy": 1,
"oldfieldname": "status",
"oldfieldtype": "Select",
"options": "\nDraft\nTo Deliver and Bill\nTo Bill\nTo Deliver\nCompleted\nStopped\nCancelled\nClosed",
"options": "\nDraft\nTo Deliver and Bill\nTo Bill\nTo Deliver\nCompleted\nCancelled\nClosed",
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,

View File

@ -160,9 +160,9 @@ class SalesOrder(SellingController):
self.update_prevdoc_status('submit')
def on_cancel(self):
# Cannot cancel stopped SO
if self.status == 'Stopped':
frappe.throw(_("Stopped order cannot be cancelled. Unstop to cancel."))
# Cannot cancel closed SO
if self.status == 'Closed':
frappe.throw(_("Closed order cannot be cancelled. Unclose to cancel."))
self.check_nextdoc_docstatus()
self.update_reserved_qty()
@ -317,7 +317,7 @@ def get_list_context(context=None):
return list_context
@frappe.whitelist()
def stop_or_unstop_sales_orders(names, status):
def close_or_unclose_sales_orders(names, status):
if not frappe.has_permission("Sales Order", "write"):
frappe.throw(_("Not permitted"), frappe.PermissionError)
@ -325,11 +325,11 @@ def stop_or_unstop_sales_orders(names, status):
for name in names:
so = frappe.get_doc("Sales Order", name)
if so.docstatus == 1:
if status in ("Stopped", "Closed"):
if so.status not in ("Stopped", "Cancelled", "Closed") and (so.per_delivered < 100 or so.per_billed < 100):
if status == "Closed":
if so.status not in ("Cancelled", "Closed") and (so.per_delivered < 100 or so.per_billed < 100):
so.update_status(status)
else:
if so.status in ("Stopped", "Closed"):
if so.status == "Closed":
so.update_status('Draft')
frappe.local.message_log = []

View File

@ -32,7 +32,7 @@ frappe.views.calendar["Sales Order"] = {
],
get_events_method: "erpnext.selling.doctype.sales_order.sales_order.get_events",
get_css_class: function(data) {
if(data.status=="Stopped") {
if(data.status=="Closed") {
return "";
} if(data.delivery_status=="Not Delivered") {
return "danger";

View File

@ -2,58 +2,51 @@ frappe.listview_settings['Sales Order'] = {
add_fields: ["base_grand_total", "customer_name", "currency", "delivery_date", "per_delivered", "per_billed",
"status", "order_type"],
get_indicator: function(doc) {
if(doc.status==="Stopped") {
return [__("Stopped"), "darkgrey", "status,=,Stopped"];
} else if(doc.status==="Closed"){
if(doc.status==="Closed"){
return [__("Closed"), "green", "status,=,Closed"];
} else if (doc.order_type !== "Maintenance"
&& flt(doc.per_delivered, 2) < 100 && frappe.datetime.get_diff(doc.delivery_date) < 0) {
// to bill & overdue
return [__("Overdue"), "red", "per_delivered,<,100|delivery_date,<,Today|status,!=,Stopped"];
return [__("Overdue"), "red", "per_delivered,<,100|delivery_date,<,Today|status,!=,Closed"];
} else if (doc.order_type !== "Maintenance"
&& flt(doc.per_delivered, 2) < 100 && doc.status!=="Stopped") {
&& flt(doc.per_delivered, 2) < 100 && doc.status!=="Closed") {
// not delivered
if(flt(doc.per_billed, 2) < 100) {
// not delivered & not billed
return [__("To Deliver and Bill"), "orange",
"per_delivered,<,100|per_billed,<,100|status,!=,Stopped"];
"per_delivered,<,100|per_billed,<,100|status,!=,Closed"];
} else {
// not billed
return [__("To Deliver"), "orange",
"per_delivered,<,100|per_billed,=,100|status,!=,Stopped"];
"per_delivered,<,100|per_billed,=,100|status,!=,Closed"];
}
} else if ((doc.order_type === "Maintenance" || flt(doc.per_delivered, 2) == 100)
&& flt(doc.per_billed, 2) < 100 && doc.status!=="Stopped") {
&& flt(doc.per_billed, 2) < 100 && doc.status!=="Closed") {
// to bill
return [__("To Bill"), "orange", "per_delivered,=,100|per_billed,<,100|status,!=,Stopped"];
return [__("To Bill"), "orange", "per_delivered,=,100|per_billed,<,100|status,!=,Closed"];
} else if((doc.order_type === "Maintenance" || flt(doc.per_delivered, 2) == 100)
&& flt(doc.per_billed, 2) == 100 && doc.status!=="Stopped") {
&& flt(doc.per_billed, 2) == 100 && doc.status!=="Closed") {
return [__("Completed"), "green", "per_delivered,=,100|per_billed,=,100|status,!=,Stopped"];
return [__("Completed"), "green", "per_delivered,=,100|per_billed,=,100|status,!=,Closed"];
}
},
onload: function(listview) {
var method = "erpnext.selling.doctype.sales_order.sales_order.stop_or_unstop_sales_orders";
var method = "erpnext.selling.doctype.sales_order.sales_order.close_or_unclose_sales_orders";
listview.page.add_menu_item(__("Close"), function() {
listview.call_for_selected_items(method, {"status": "Closed"});
});
listview.page.add_menu_item(__("Stop"), function() {
listview.call_for_selected_items(method, {"status": "Stoped"});
});
listview.page.add_menu_item(__("Re-open"), function() {
listview.call_for_selected_items(method, {"status": "Unstop"});
listview.call_for_selected_items(method, {"status": "Submitted"});
});
}

View File

@ -93,12 +93,12 @@ class TestSalesOrder(unittest.TestCase):
dn = create_dn_against_so(so.name)
self.assertEqual(get_reserved_qty(), existing_reserved_qty + 5)
# stop so
# close so
so.load_from_db()
so.update_status("Stopped")
so.update_status("Closed")
self.assertEqual(get_reserved_qty(), existing_reserved_qty)
# unstop so
# unclose so
so.load_from_db()
so.update_status('Draft')
self.assertEqual(get_reserved_qty(), existing_reserved_qty + 5)
@ -143,14 +143,14 @@ class TestSalesOrder(unittest.TestCase):
self.assertEqual(get_reserved_qty("_Test Item Home Desktop 100"),
existing_reserved_qty_item2 + 10)
# stop so
# close so
so.load_from_db()
so.update_status("Stopped")
so.update_status("Closed")
self.assertEqual(get_reserved_qty("_Test Item"), existing_reserved_qty_item1)
self.assertEqual(get_reserved_qty("_Test Item Home Desktop 100"), existing_reserved_qty_item2)
# unstop so
# unclose so
so.load_from_db()
so.update_status('Draft')

View File

@ -15,7 +15,7 @@ def get_notification_config():
"Opportunity": {"status": "Open"},
"Quotation": {"docstatus": 0},
"Sales Order": {
"status": ("not in", ("Stopped", "Completed", "Closed")),
"status": ("not in", ("Completed", "Closed")),
"docstatus": ("<", 2)
},
"Journal Entry": {"docstatus": 0},
@ -29,7 +29,7 @@ def get_notification_config():
"Stock Entry": {"docstatus": 0},
"Material Request": {"docstatus": 0},
"Purchase Order": {
"status": ("not in", ("Stopped", "Completed", "Closed")),
"status": ("not in", ("Completed", "Closed")),
"docstatus": ("<", 2)
},
"Production Order": { "status": "In Process" },

View File

@ -34,7 +34,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
source_doctype: "Sales Order",
get_query_filters: {
docstatus: 1,
status: ["not in", ["Stopped", "Closed"]],
status: ["!=", "Closed"],
per_delivered: ["<", 99.99],
project_name: cur_frm.doc.project_name || undefined,
customer: cur_frm.doc.customer || undefined,

View File

@ -98,7 +98,7 @@ class DeliveryNote(SellingController):
self.set_status()
self.so_required()
self.validate_proj_cust()
self.check_stop_or_close_sales_order("against_sales_order")
self.check_close_sales_order("against_sales_order")
self.validate_for_items()
self.validate_warehouse()
self.validate_uom_is_integer("stock_uom", "qty")
@ -195,7 +195,7 @@ class DeliveryNote(SellingController):
self.make_gl_entries()
def on_cancel(self):
self.check_stop_or_close_sales_order("against_sales_order")
self.check_close_sales_order("against_sales_order")
self.check_next_docstatus()
self.update_prevdoc_status()

View File

@ -70,7 +70,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten
source_doctype: "Sales Order",
get_query_filters: {
docstatus: 1,
status: ["!=", "Stopped"],
status: ["!=", "Closed"],
per_delivered: ["<", 99.99],
company: cur_frm.doc.company
}

View File

@ -101,7 +101,7 @@ class MaterialRequest(BuyingController):
def on_cancel(self):
pc_obj = frappe.get_doc('Purchase Common')
pc_obj.check_for_stopped_or_closed_status(self.doctype, self.name)
pc_obj.check_for_closed_status(self.doctype, self.name)
pc_obj.check_docstatus(check = 'Next', doctype = 'Purchase Order', docname = self.name, detail_doctype = 'Purchase Order Item')
self.update_requested_qty()

View File

@ -46,7 +46,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
get_query_filters: {
supplier: cur_frm.doc.supplier || undefined,
docstatus: 1,
status: ["not in", ["Stopped", "Closed"]],
status: ["!=", "Closed"],
per_received: ["<", 99.99],
company: cur_frm.doc.company
}

View File

@ -61,7 +61,7 @@ class PurchaseReceipt(BuyingController):
pc_obj = frappe.get_doc('Purchase Common')
pc_obj.validate_for_items(self)
self.check_for_stopped_or_closed_status(pc_obj)
self.check_for_closed_status(pc_obj)
# sub-contracting
self.validate_for_subcontracting()
@ -177,8 +177,8 @@ class PurchaseReceipt(BuyingController):
if po and po_item_rows:
po_obj = frappe.get_doc("Purchase Order", po)
if po_obj.status in ["Stopped", "Cancelled"]:
frappe.throw(_("{0} {1} is cancelled or stopped").format(_("Purchase Order"), po),
if po_obj.status in ["Closed", "Cancelled"]:
frappe.throw(_("{0} {1} is cancelled or closed").format(_("Purchase Order"), po),
frappe.InvalidStatusError)
po_obj.update_ordered_qty(po_item_rows)
@ -212,13 +212,13 @@ class PurchaseReceipt(BuyingController):
if self.docstatus==1:
raise frappe.ValidationError
# Check for Stopped status
def check_for_stopped_or_closed_status(self, pc_obj):
# Check for Closed status
def check_for_closed_status(self, pc_obj):
check_list =[]
for d in self.get('items'):
if d.meta.get_field('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
check_list.append(d.prevdoc_docname)
pc_obj.check_for_stopped_or_closed_status(d.prevdoc_doctype, d.prevdoc_docname)
pc_obj.check_for_closed_status(d.prevdoc_doctype, d.prevdoc_docname)
# on submit
def on_submit(self):
@ -256,7 +256,7 @@ class PurchaseReceipt(BuyingController):
def on_cancel(self):
pc_obj = frappe.get_doc('Purchase Common')
self.check_for_stopped_or_closed_status(pc_obj)
self.check_for_closed_status(pc_obj)
# Check if Purchase Invoice has been submitted against current Purchase Order
submitted = frappe.db.sql("""select t1.name
from `tabPurchase Invoice` t1,`tabPurchase Invoice Item` t2

View File

@ -92,7 +92,7 @@ def get_reserved_qty(item_code, warehouse):
and parenttype="Sales Order"
and item_code != parent_item
and exists (select * from `tabSales Order` so
where name = dnpi_in.parent and docstatus = 1 and status not in ('Stopped','Closed'))
where name = dnpi_in.parent and docstatus = 1 and status != 'Closed')
) dnpi)
union
(select qty as dnpi_qty, qty as so_item_qty,
@ -102,7 +102,7 @@ def get_reserved_qty(item_code, warehouse):
and (so_item.delivered_by_supplier is null or so_item.delivered_by_supplier = 0)
and exists(select * from `tabSales Order` so
where so.name = so_item.parent and so.docstatus = 1
and so.status not in ('Stopped','Closed')))
and so.status != 'Closed'))
) tab
where
so_item_qty >= so_item_delivered_qty
@ -125,7 +125,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 > po_item.received_qty and po_item.parent=po.name
and po.status not in ('Stopped', 'Closed', 'Delivered') and po.docstatus=1
and po.status not in ('Closed', 'Delivered') and po.docstatus=1
and po_item.delivered_by_supplier = 0""", (item_code, warehouse))
return flt(ordered_qty[0][0]) if ordered_qty else 0