From 2d1dd034838d2223ac6f09d44fd6cf5b8586a54f Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 07:03:03 +0000 Subject: [PATCH] fix(stock): handle NoneType error (backport #53593) (#53627) Co-authored-by: Pandiyan P fix(stock): handle NoneType error (#53593) --- erpnext/stock/doctype/purchase_receipt/purchase_receipt.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index 8cbe865f072..45353633a15 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -404,7 +404,7 @@ class PurchaseReceipt(BuyingController): self.update_received_qty_if_from_pp() def update_received_qty_if_from_pp(self): - from frappe.query_builder.functions import Sum + from frappe.query_builder.functions import Coalesce, Sum items_from_po = [item.purchase_order_item for item in self.items if item.purchase_order_item] if items_from_po: @@ -413,7 +413,10 @@ class PurchaseReceipt(BuyingController): frappe.qb.from_(table) .select(table.production_plan_sub_assembly_item) .distinct() - .where(table.name.isin(items_from_po) & table.production_plan_sub_assembly_item.isnotnull()) + .where( + table.name.isin(items_from_po) + & Coalesce(table.production_plan_sub_assembly_item, "").ne("") + ) ) result = subquery.run(as_dict=True) if result: