mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 21:59:13 +00:00
[fix] status updater
This commit is contained in:
@@ -37,7 +37,7 @@ class PurchaseOrder(BuyingController):
|
|||||||
if not self.status:
|
if not self.status:
|
||||||
self.status = "Draft"
|
self.status = "Draft"
|
||||||
|
|
||||||
from erpnext.utilities import validate_status
|
from erpnext.controllers.status_updater import validate_status
|
||||||
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
||||||
"Cancelled"])
|
"Cancelled"])
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class SupplierQuotation(BuyingController):
|
|||||||
if not self.status:
|
if not self.status:
|
||||||
self.status = "Draft"
|
self.status = "Draft"
|
||||||
|
|
||||||
from erpnext.utilities import validate_status
|
from erpnext.controllers.status_updater import validate_status
|
||||||
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
||||||
"Cancelled"])
|
"Cancelled"])
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,14 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt, comma_or
|
||||||
from frappe import msgprint, _, throw
|
from frappe import msgprint, _, throw
|
||||||
from frappe.model.document import Document
|
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 = {
|
status_map = {
|
||||||
"Lead": [
|
"Lead": [
|
||||||
["Converted", "has_customer"],
|
["Converted", "has_customer"],
|
||||||
@@ -30,6 +34,16 @@ status_map = {
|
|||||||
["Stopped", "eval:self.status=='Stopped'"],
|
["Stopped", "eval:self.status=='Stopped'"],
|
||||||
["Cancelled", "eval:self.docstatus==2"],
|
["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):
|
class StatusUpdater(Document):
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class Attendance(Document):
|
|||||||
frappe.throw(_("Employee {0} is not active or does not exist").format(self.employee))
|
frappe.throw(_("Employee {0} is not active or does not exist").format(self.employee))
|
||||||
|
|
||||||
def validate(self):
|
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
|
from erpnext.accounts.utils import validate_fiscal_year
|
||||||
validate_status(self.status, ["Present", "Absent", "Half Day"])
|
validate_status(self.status, ["Present", "Absent", "Half Day"])
|
||||||
validate_fiscal_year(self.att_date, self.fiscal_year, _("Attendance Date"), self)
|
validate_fiscal_year(self.att_date, self.fiscal_year, _("Attendance Date"), self)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class Employee(Document):
|
|||||||
self.employee = self.name
|
self.employee = self.name
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
from erpnext.utilities import validate_status
|
from erpnext.controllers.status_updater import validate_status
|
||||||
validate_status(self.status, ["Active", "Left"])
|
validate_status(self.status, ["Active", "Left"])
|
||||||
|
|
||||||
self.employee = self.name
|
self.employee = self.name
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class ProductionOrder(Document):
|
|||||||
if self.docstatus == 0:
|
if self.docstatus == 0:
|
||||||
self.status = "Draft"
|
self.status = "Draft"
|
||||||
|
|
||||||
from erpnext.utilities import validate_status
|
from erpnext.controllers.status_updater import validate_status
|
||||||
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
||||||
"In Process", "Completed", "Cancelled"])
|
"In Process", "Completed", "Cancelled"])
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class SalesOrder(SellingController):
|
|||||||
if not self.status:
|
if not self.status:
|
||||||
self.status = "Draft"
|
self.status = "Draft"
|
||||||
|
|
||||||
from erpnext.utilities import validate_status
|
from erpnext.controllers.status_updater import validate_status
|
||||||
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
validate_status(self.status, ["Draft", "Submitted", "Stopped",
|
||||||
"Cancelled"])
|
"Cancelled"])
|
||||||
|
|
||||||
|
|||||||
@@ -91,10 +91,7 @@ class DeliveryNote(SellingController):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
super(DeliveryNote, self).validate()
|
super(DeliveryNote, self).validate()
|
||||||
|
self.set_status()
|
||||||
from erpnext.utilities import validate_status
|
|
||||||
validate_status(self.status, ["Draft", "Submitted", "Cancelled"])
|
|
||||||
|
|
||||||
self.so_required()
|
self.so_required()
|
||||||
self.validate_proj_cust()
|
self.validate_proj_cust()
|
||||||
self.check_stop_sales_order("against_sales_order")
|
self.check_stop_sales_order("against_sales_order")
|
||||||
@@ -108,7 +105,6 @@ class DeliveryNote(SellingController):
|
|||||||
|
|
||||||
self.update_current_stock()
|
self.update_current_stock()
|
||||||
|
|
||||||
if not self.status: self.status = 'Draft'
|
|
||||||
if not self.installation_status: self.installation_status = 'Not Installed'
|
if not self.installation_status: self.installation_status = 'Not Installed'
|
||||||
|
|
||||||
def validate_with_previous_doc(self):
|
def validate_with_previous_doc(self):
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class MaterialRequest(BuyingController):
|
|||||||
if not self.status:
|
if not self.status:
|
||||||
self.status = "Draft"
|
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"])
|
validate_status(self.status, ["Draft", "Submitted", "Stopped", "Cancelled"])
|
||||||
|
|
||||||
self.validate_value("material_request_type", "in", ["Purchase", "Material Transfer", "Material Issue"])
|
self.validate_value("material_request_type", "in", ["Purchase", "Material Transfer", "Material Issue"])
|
||||||
|
|||||||
@@ -42,13 +42,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
super(PurchaseReceipt, self).validate()
|
super(PurchaseReceipt, self).validate()
|
||||||
|
|
||||||
self.po_required()
|
self.po_required()
|
||||||
|
self.set_status()
|
||||||
if not self.status:
|
|
||||||
self.status = "Draft"
|
|
||||||
|
|
||||||
from erpnext.utilities import validate_status
|
|
||||||
validate_status(self.status, ["Draft", "Submitted", "Cancelled"])
|
|
||||||
|
|
||||||
self.validate_with_previous_doc()
|
self.validate_with_previous_doc()
|
||||||
self.validate_rejected_warehouse()
|
self.validate_rejected_warehouse()
|
||||||
self.validate_accepted_rejected_qty()
|
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
|
from erpnext.controllers.status_updater import StatusUpdater
|
||||||
|
|
||||||
class Contact(StatusUpdater):
|
class Contact(StatusUpdater):
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
# concat first and last name
|
# concat first and last name
|
||||||
self.name = " ".join(filter(None,
|
self.name = " ".join(filter(None,
|
||||||
|
|||||||
Reference in New Issue
Block a user