From 2880469706fc69778218849b231dc2166801912b Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Mon, 5 Dec 2022 22:47:05 +0530 Subject: [PATCH 1/5] fix: order status in `Production Planning Report` (cherry picked from commit 632c08f7e0b0c6a932457afdfa484f7668e9a9e5) --- .../production_planning_report.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/erpnext/manufacturing/report/production_planning_report/production_planning_report.py b/erpnext/manufacturing/report/production_planning_report/production_planning_report.py index 16c25ce7e6d..109d9ab656b 100644 --- a/erpnext/manufacturing/report/production_planning_report/production_planning_report.py +++ b/erpnext/manufacturing/report/production_planning_report/production_planning_report.py @@ -49,7 +49,7 @@ class ProductionPlanReport(object): parent.bom_no, parent.fg_warehouse.as_("warehouse"), ) - .where(parent.status.notin(["Completed", "Stopped"])) + .where(parent.status.notin(["Completed", "Stopped", "Closed"])) ) if order_by == "Planned Start Date": @@ -79,10 +79,11 @@ class ProductionPlanReport(object): query = query.where(child.parent.isin(self.filters.docnames)) if doctype == "Sales Order": - query = query.select( - child.delivery_date, - parent.base_grand_total, - ).where((child.stock_qty > child.produced_qty) & (parent.per_delivered < 100.0)) + query = query.select(child.delivery_date, parent.base_grand_total,).where( + (child.stock_qty > child.produced_qty) + & (parent.per_delivered < 100.0) + & (parent.status.notin(["Completed", "Closed"])) + ) if order_by == "Delivery Date": query = query.orderby(child.delivery_date, order=Order.asc) @@ -91,7 +92,9 @@ class ProductionPlanReport(object): elif doctype == "Material Request": query = query.select(child.schedule_date,).where( - (parent.per_ordered < 100) & (parent.material_request_type == "Manufacture") + (parent.per_ordered < 100) + & (parent.material_request_type == "Manufacture") + & (parent.status != "Stopped") ) if order_by == "Required Date": From 45f79ef6444b9ae99603fa4b5a731a80a4e69636 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 12 Dec 2022 13:02:08 +0530 Subject: [PATCH 2/5] perf: add indexes on payment entry reference (backport #33288) (#33290) perf: add indexes on payment entry reference (#33288) Adds index on: 1. reference doctype 2. reference name *Why not composite index?* There are three type of queries on this doctype - filtering ref_doctype - doctype index helps here - filtering ref_name - name index helps here - filtering both - name index helps here too. Since it has sufficiently high cardinality. Composite index wont help in case where ref_doctype isn't specfied. [skip ci] (cherry picked from commit 593626f5022bd5af1241e8c5ecb807c04943bd42) Co-authored-by: Ankush Menat --- .../payment_entry_reference/payment_entry_reference.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json index 8961167f018..3003c68196e 100644 --- a/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json +++ b/erpnext/accounts/doctype/payment_entry_reference/payment_entry_reference.json @@ -25,7 +25,8 @@ "in_list_view": 1, "label": "Type", "options": "DocType", - "reqd": 1 + "reqd": 1, + "search_index": 1 }, { "columns": 2, @@ -35,7 +36,8 @@ "in_list_view": 1, "label": "Name", "options": "reference_doctype", - "reqd": 1 + "reqd": 1, + "search_index": 1 }, { "fieldname": "due_date", @@ -104,7 +106,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2021-09-26 17:06:55.597389", + "modified": "2022-12-12 12:31:44.919895", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Entry Reference", @@ -113,5 +115,6 @@ "quick_entry": 1, "sort_field": "modified", "sort_order": "DESC", + "states": [], "track_changes": 1 } \ No newline at end of file From 988a327b58b6dee234103c86f552b1d705e1d4df Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Fri, 9 Dec 2022 22:41:43 +0530 Subject: [PATCH 3/5] fix: `Material Request` reference in internal `Sales Order` (cherry picked from commit 78b438f6cf952829cbac907203f0f31584add668) --- erpnext/selling/doctype/sales_order/sales_order_dashboard.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/sales_order/sales_order_dashboard.py b/erpnext/selling/doctype/sales_order/sales_order_dashboard.py index ace2e29c2b4..5c4b57813d3 100644 --- a/erpnext/selling/doctype/sales_order/sales_order_dashboard.py +++ b/erpnext/selling/doctype/sales_order/sales_order_dashboard.py @@ -12,7 +12,10 @@ def get_data(): "Auto Repeat": "reference_document", "Maintenance Visit": "prevdoc_docname", }, - "internal_links": {"Quotation": ["items", "prevdoc_docname"]}, + "internal_links": { + "Quotation": ["items", "prevdoc_docname"], + "Material Request": ["items", "material_request"], + }, "transactions": [ { "label": _("Fulfillment"), From b17ac522f5aa5d16d77f048999dd1f5abd8bb402 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Mon, 12 Dec 2022 20:15:59 +0530 Subject: [PATCH 4/5] fix: incorrect balance on parent company due to key mismatch (cherry picked from commit 7b3316dc3175bcdd6c2c592d9abdb13ab477f015) --- .../consolidated_financial_statement.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py index 330e442a808..6c8f4bb6fe9 100644 --- a/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py +++ b/erpnext/accounts/report/consolidated_financial_statement/consolidated_financial_statement.py @@ -533,12 +533,13 @@ def get_accounts(root_type, companies): ], filters={"company": company, "root_type": root_type}, ): - if account.account_name not in added_accounts: + if account.account_number: + account_key = account.account_number + "-" + account.account_name + else: + account_key = account.account_name + + if account_key not in added_accounts: accounts.append(account) - if account.account_number: - account_key = account.account_number + "-" + account.account_name - else: - account_key = account.account_name added_accounts.append(account_key) return accounts From 50b2898a2c13ffe5a71eea3242b771d11ba8abb5 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Sat, 10 Dec 2022 14:00:29 +0530 Subject: [PATCH 5/5] fix: `Enough Parts to Build` in `BOM Stock Report` (cherry picked from commit 723c64ba738b027323487500f09dfd7cafe3468d) --- .../report/bom_stock_report/bom_stock_report.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.py b/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.py index 1e1b4356008..cdf1541f888 100644 --- a/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.py +++ b/erpnext/manufacturing/report/bom_stock_report/bom_stock_report.py @@ -4,7 +4,7 @@ import frappe from frappe import _ -from frappe.query_builder.functions import Floor, Sum +from frappe.query_builder.functions import Sum from pypika.terms import ExistsCriterion @@ -58,9 +58,9 @@ def get_bom_stock(filters): bom_item.description, bom_item.stock_qty, bom_item.stock_uom, - bom_item.stock_qty * qty_to_produce / bom.quantity, - Sum(bin.actual_qty).as_("actual_qty"), - Sum(Floor(bin.actual_qty / (bom_item.stock_qty * qty_to_produce / bom.quantity))), + (bom_item.stock_qty / bom.quantity) * qty_to_produce, + Sum(bin.actual_qty), + Sum(bin.actual_qty) / (bom_item.stock_qty / bom.quantity), ) .where((bom_item.parent == filters.get("bom")) & (bom_item.parenttype == "BOM")) .groupby(bom_item.item_code)