fix: validate sales order linked work order creation on server side

This commit is contained in:
Mangesh-Khairnar 2019-03-06 10:36:18 +05:30
parent bcb8b135f2
commit c423d6f2e4

View File

@ -56,6 +56,7 @@ class WorkOrder(Document):
def validate_sales_order(self):
if self.sales_order:
self.check_sales_order_on_hold_or_close()
so = frappe.db.sql("""
select so.name, so_item.delivery_date, so.project
from `tabSales Order` so
@ -91,6 +92,11 @@ class WorkOrder(Document):
else:
frappe.throw(_("Sales Order {0} is not valid").format(self.sales_order))
def check_sales_order_on_hold_or_close(self):
status = frappe.db.get_value("Sales Order", self.sales_order, "status")
if status in ("Closed", "On Hold"):
frappe.throw(_("Sales Order {0} is {1}").format(self.sales_order, status))
def set_default_warehouse(self):
if not self.wip_warehouse:
self.wip_warehouse = frappe.db.get_single_value("Manufacturing Settings", "default_wip_warehouse")