From 649d18c4f73beeb7880349d611938b8cbf500839 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 21 Jul 2014 17:17:59 +0530 Subject: [PATCH] [minor] fix server error for new production order if sales order is invalid --- .../doctype/production_order/production_order.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 2d41d0a6a4..1486d2a684 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -39,16 +39,16 @@ class ProductionOrder(Document): def validate_sales_order(self): if self.sales_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) - if not self.expected_delivery_date: - self.expected_delivery_date = so.delivery_date - - self.validate_production_order_against_so() - def validate_warehouse(self): from erpnext.stock.utils import validate_warehouse_company