[minor] fix server error for new production order if sales order is invalid
This commit is contained in:
parent
cbf0cb7de7
commit
649d18c4f7
@ -39,16 +39,16 @@ class ProductionOrder(Document):
|
|||||||
def validate_sales_order(self):
|
def validate_sales_order(self):
|
||||||
if self.sales_order:
|
if self.sales_order:
|
||||||
so = frappe.db.sql("""select name, delivery_date from `tabSales Order`
|
so = frappe.db.sql("""select name, delivery_date from `tabSales Order`
|
||||||
where name=%s and docstatus = 1""", self.sales_order, as_dict=1)[0]
|
where name=%s and docstatus = 1""", self.sales_order, as_dict=1)
|
||||||
|
|
||||||
if not so.name:
|
if len(so):
|
||||||
|
if not self.expected_delivery_date:
|
||||||
|
self.expected_delivery_date = so[0].delivery_date
|
||||||
|
|
||||||
|
self.validate_production_order_against_so()
|
||||||
|
else:
|
||||||
frappe.throw(_("Sales Order {0} is not valid") % self.sales_order)
|
frappe.throw(_("Sales Order {0} is not valid") % self.sales_order)
|
||||||
|
|
||||||
if not self.expected_delivery_date:
|
|
||||||
self.expected_delivery_date = so.delivery_date
|
|
||||||
|
|
||||||
self.validate_production_order_against_so()
|
|
||||||
|
|
||||||
def validate_warehouse(self):
|
def validate_warehouse(self):
|
||||||
from erpnext.stock.utils import validate_warehouse_company
|
from erpnext.stock.utils import validate_warehouse_company
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user