From 7935d186f99c295111fcdc667dd59bb980bf2d13 Mon Sep 17 00:00:00 2001 From: Neil Lasrado Date: Tue, 26 Sep 2017 13:43:30 +0530 Subject: [PATCH] Auto set warehouses in Production Order if default warehouses are set in Manufacturing Settings and not mentioned in Production Order --- .../doctype/production_order/production_order.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index f4d37760d3..a634bf269c 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -35,6 +35,7 @@ class ProductionOrder(Document): validate_bom_no(self.production_item, self.bom_no) self.validate_sales_order() + self.set_default_warehouse() self.validate_warehouse_belongs_to_company() self.calculate_operating_cost() self.validate_qty() @@ -69,6 +70,12 @@ class ProductionOrder(Document): else: frappe.throw(_("Sales Order {0} is not valid").format(self.sales_order)) + def set_default_warehouse(self): + if not self.wip_warehouse: + self.wip_warehouse = frappe.db.get_single_value("Manufacturing Settings", "default_wip_warehouse") + if not self.fg_warehouse: + self.fg_warehouse = frappe.db.get_single_value("Manufacturing Settings", "default_fg_warehouse") + def validate_warehouse_belongs_to_company(self): warehouses = [self.fg_warehouse, self.wip_warehouse] for d in self.get("required_items"):