From 846ff323e2ef5853b3fe1af614b9589de93df6e2 Mon Sep 17 00:00:00 2001 From: pateljannat Date: Tue, 3 Nov 2020 17:35:44 +0530 Subject: [PATCH 1/2] feat: sales order status filter for production plan --- .../doctype/production_plan/production_plan.json | 10 +++++++++- .../doctype/production_plan/production_plan.py | 6 ++++-- .../doctype/production_plan/test_production_plan.py | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.json b/erpnext/manufacturing/doctype/production_plan/production_plan.json index 850d5aeff8..63df5f379d 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.json +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.json @@ -19,6 +19,7 @@ "column_break2", "from_date", "to_date", + "sales_order_status", "sales_orders_detail", "get_sales_orders", "sales_orders", @@ -301,13 +302,20 @@ "label": "Warehouses", "options": "Production Plan Material Request Warehouse", "read_only": 1 + }, + { + "depends_on": "eval: doc.get_items_from == \"Sales Order\"", + "fieldname": "sales_order_status", + "fieldtype": "Select", + "label": "Sales Order Status", + "options": "\nDraft\nOn Hold\nTo Deliver and Bill\nTo Bill\nTo Deliver\nCompleted\nCancelled\nClosed" } ], "icon": "fa fa-calendar", "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2020-10-26 13:00:54.335319", + "modified": "2020-11-03 15:19:18.270529", "modified_by": "Administrator", "module": "Manufacturing", "name": "Production Plan", diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py index a314a15c23..3833e86d27 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py @@ -571,6 +571,8 @@ def get_sales_orders(self): so_filter += " and so.customer = %(customer)s" if self.project: so_filter += " and so.project = %(project)s" + if self.sales_order_status: + so_filter += "and so.status = %(sales_order_status)s" if self.item_code: item_filter += " and so_item.item_code = %(item)s" @@ -594,8 +596,8 @@ def get_sales_orders(self): "customer": self.customer, "project": self.project, "item": self.item_code, - "company": self.company - + "company": self.company, + "sales_order_status": self.sales_order_status }, as_dict=1) return open_so diff --git a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py index fa9d080cca..27335aa204 100644 --- a/erpnext/manufacturing/doctype/production_plan/test_production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/test_production_plan.py @@ -137,7 +137,8 @@ class TestProductionPlan(unittest.TestCase): 'from_date': so.transaction_date, 'to_date': so.transaction_date, 'customer': so.customer, - 'item_code': item + 'item_code': item, + 'sales_order_status': so.status }) sales_orders = get_sales_orders(pln) or {} sales_orders = [d.get('name') for d in sales_orders if d.get('name') == sales_order] From d08c91673af3c21f77b402e6d1ee53bf9548344a Mon Sep 17 00:00:00 2001 From: pateljannat Date: Tue, 10 Nov 2020 18:04:30 +0530 Subject: [PATCH 2/2] fix: removed unnecessary filter options --- .../doctype/production_plan/production_plan.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.json b/erpnext/manufacturing/doctype/production_plan/production_plan.json index 63df5f379d..7daf7069f3 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.json +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.json @@ -308,14 +308,14 @@ "fieldname": "sales_order_status", "fieldtype": "Select", "label": "Sales Order Status", - "options": "\nDraft\nOn Hold\nTo Deliver and Bill\nTo Bill\nTo Deliver\nCompleted\nCancelled\nClosed" + "options": "\nTo Deliver and Bill\nTo Bill\nTo Deliver" } ], "icon": "fa fa-calendar", "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2020-11-03 15:19:18.270529", + "modified": "2020-11-10 18:01:54.991970", "modified_by": "Administrator", "module": "Manufacturing", "name": "Production Plan",