[fix] status updater
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 6b7c9a2..220dff2 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -37,7 +37,7 @@
if not self.status:
self.status = "Draft"
- from erpnext.utilities import validate_status
+ from erpnext.controllers.status_updater import validate_status
validate_status(self.status, ["Draft", "Submitted", "Stopped",
"Cancelled"])
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
index 5f9a46d..2beb559 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
@@ -18,7 +18,7 @@
if not self.status:
self.status = "Draft"
- from erpnext.utilities import validate_status
+ from erpnext.controllers.status_updater import validate_status
validate_status(self.status, ["Draft", "Submitted", "Stopped",
"Cancelled"])
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index 0109b68..2f83cb9 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -3,10 +3,14 @@
from __future__ import unicode_literals
import frappe
-from frappe.utils import flt
+from frappe.utils import flt, comma_or
from frappe import msgprint, _, throw
from frappe.model.document import Document
+def validate_status(status, options):
+ if status not in options:
+ frappe.throw(_("Status must be one of {0}").format(comma_or(options)))
+
status_map = {
"Lead": [
["Converted", "has_customer"],
@@ -30,6 +34,16 @@
["Stopped", "eval:self.status=='Stopped'"],
["Cancelled", "eval:self.docstatus==2"],
],
+ "Delivery Note": [
+ ["Draft", None],
+ ["Submitted", "eval:self.docstatus==1"],
+ ["Cancelled", "eval:self.docstatus==2"],
+ ],
+ "Purchase Receipt": [
+ ["Draft", None],
+ ["Submitted", "eval:self.docstatus==1"],
+ ["Cancelled", "eval:self.docstatus==2"],
+ ]
}
class StatusUpdater(Document):
diff --git a/erpnext/hr/doctype/attendance/attendance.py b/erpnext/hr/doctype/attendance/attendance.py
index 61a1662..7d6c8ad 100644
--- a/erpnext/hr/doctype/attendance/attendance.py
+++ b/erpnext/hr/doctype/attendance/attendance.py
@@ -40,7 +40,7 @@
frappe.throw(_("Employee {0} is not active or does not exist").format(self.employee))
def validate(self):
- from erpnext.utilities import validate_status
+ from erpnext.controllers.status_updater import validate_status
from erpnext.accounts.utils import validate_fiscal_year
validate_status(self.status, ["Present", "Absent", "Half Day"])
validate_fiscal_year(self.att_date, self.fiscal_year, _("Attendance Date"), self)
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index 72a2686..cb0ce11 100644
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -32,7 +32,7 @@
self.employee = self.name
def validate(self):
- from erpnext.utilities import validate_status
+ from erpnext.controllers.status_updater import validate_status
validate_status(self.status, ["Active", "Left"])
self.employee = self.name
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index 62eb400..6cd2ad2 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -26,7 +26,7 @@
if self.docstatus == 0:
self.status = "Draft"
- from erpnext.utilities import validate_status
+ from erpnext.controllers.status_updater import validate_status
validate_status(self.status, ["Draft", "Submitted", "Stopped",
"In Process", "Completed", "Cancelled"])
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 398e1e1..feffc4f 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -97,7 +97,7 @@
if not self.status:
self.status = "Draft"
- from erpnext.utilities import validate_status
+ from erpnext.controllers.status_updater import validate_status
validate_status(self.status, ["Draft", "Submitted", "Stopped",
"Cancelled"])
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index 9127e24..831e537 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -91,10 +91,7 @@
def validate(self):
super(DeliveryNote, self).validate()
-
- from erpnext.utilities import validate_status
- validate_status(self.status, ["Draft", "Submitted", "Cancelled"])
-
+ self.set_status()
self.so_required()
self.validate_proj_cust()
self.check_stop_sales_order("against_sales_order")
@@ -108,7 +105,6 @@
self.update_current_stock()
- if not self.status: self.status = 'Draft'
if not self.installation_status: self.installation_status = 'Not Installed'
def validate_with_previous_doc(self):
diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py
index 5b61a6c..c1be1fd 100644
--- a/erpnext/stock/doctype/material_request/material_request.py
+++ b/erpnext/stock/doctype/material_request/material_request.py
@@ -67,7 +67,7 @@
if not self.status:
self.status = "Draft"
- from erpnext.utilities import validate_status
+ from erpnext.controllers.status_updater import validate_status
validate_status(self.status, ["Draft", "Submitted", "Stopped", "Cancelled"])
self.validate_value("material_request_type", "in", ["Purchase", "Material Transfer", "Material Issue"])
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 9813251..44fc0cc 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -42,13 +42,7 @@
super(PurchaseReceipt, self).validate()
self.po_required()
-
- if not self.status:
- self.status = "Draft"
-
- from erpnext.utilities import validate_status
- validate_status(self.status, ["Draft", "Submitted", "Cancelled"])
-
+ self.set_status()
self.validate_with_previous_doc()
self.validate_rejected_warehouse()
self.validate_accepted_rejected_qty()
diff --git a/erpnext/utilities/__init__.py b/erpnext/utilities/__init__.py
index fd4e841..e69de29 100644
--- a/erpnext/utilities/__init__.py
+++ b/erpnext/utilities/__init__.py
@@ -1,24 +0,0 @@
-# ERPNext - web based ERP (http://erpnext.com)
-# Copyright (C) 2012 Frappe Technologies Pvt Ltd
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import unicode_literals
-import frappe
-from frappe import _
-from frappe.utils import cint, comma_or
-
-def validate_status(status, options):
- if status not in options:
- frappe.throw(_("Status must be one of {0}").format(comma_or(options)))
diff --git a/erpnext/utilities/doctype/contact/contact.py b/erpnext/utilities/doctype/contact/contact.py
index c99eaa0..4158d75 100644
--- a/erpnext/utilities/doctype/contact/contact.py
+++ b/erpnext/utilities/doctype/contact/contact.py
@@ -8,7 +8,6 @@
from erpnext.controllers.status_updater import StatusUpdater
class Contact(StatusUpdater):
-
def autoname(self):
# concat first and last name
self.name = " ".join(filter(None,