[fix] status updater
This commit is contained in:
parent
0718292bfa
commit
9dd8aab211
@ -37,7 +37,7 @@ class PurchaseOrder(BuyingController):
|
||||
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"])
|
||||
|
||||
|
@ -18,7 +18,7 @@ class SupplierQuotation(BuyingController):
|
||||
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"])
|
||||
|
||||
|
@ -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 @@ status_map = {
|
||||
["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):
|
||||
|
@ -40,7 +40,7 @@ class Attendance(Document):
|
||||
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)
|
||||
|
@ -32,7 +32,7 @@ class Employee(Document):
|
||||
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
|
||||
|
@ -26,7 +26,7 @@ class ProductionOrder(Document):
|
||||
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"])
|
||||
|
||||
|
@ -97,7 +97,7 @@ class SalesOrder(SellingController):
|
||||
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"])
|
||||
|
||||
|
@ -91,10 +91,7 @@ class DeliveryNote(SellingController):
|
||||
|
||||
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 @@ class DeliveryNote(SellingController):
|
||||
|
||||
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):
|
||||
|
@ -67,7 +67,7 @@ class MaterialRequest(BuyingController):
|
||||
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"])
|
||||
|
@ -42,13 +42,7 @@ class PurchaseReceipt(BuyingController):
|
||||
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()
|
||||
|
@ -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)))
|
@ -8,7 +8,6 @@ from frappe.utils import cstr, extract_email_id
|
||||
from erpnext.controllers.status_updater import StatusUpdater
|
||||
|
||||
class Contact(StatusUpdater):
|
||||
|
||||
def autoname(self):
|
||||
# concat first and last name
|
||||
self.name = " ".join(filter(None,
|
||||
|
Loading…
x
Reference in New Issue
Block a user