Auto Reorder check in group does not check children warehouses

Hello,

I have a question regarding the intended use of the auto reorder levels.
Given is the following exemplary warehouse tree:

Store → A → A-1 → A-1-B

So we have multiple levels of warehouses. Now given an item that has stock in A-1-B, I get a “Bin” for this warehouse containing the actual and projected qty etc. of said item (>0).

If I now set a auto reorder level to check in the group warehouse “Store”, “erpnext.stock.reorder_item.reorder_item” check for the Bin with the warehouse “Store”, which always returns 0 for actual and projected qty.
Thus, ERPNext will trigger a Material Request despite the fact that this reorder level has not been reached yet due to there being quantities available in the child warehouse “A-1-B”.

Interesting to note: I have no documents of type “Bin” in the system for the intermediary groups in the warehouse tree. Only for the actual warehouse leaf/endpoint and for the root node.

Is this working as intended or am I not getting the whole picture here? Many thanks for any hints or help in advance.

Greetings
ppd

Edit: I made a quick fix that allows the projected qty calculation to propagate beyond the first parent level. See attached patch. Seems simple enough

From 78458695d75e553b7407ce2bb4d1260bfa5509ef Mon Sep 17 00:00:00 2001
From: ppd <*@*.*>
Date: Thu, 14 Sep 2017 12:56:30 +0000
Subject: [PATCH] Fix check in group functionality of item reorder

---
 erpnext/stock/reorder_item.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/erpnext/stock/reorder_item.py b/erpnext/stock/reorder_item.py
index 01a6a6d..9de5d72 100644
--- a/erpnext/stock/reorder_item.py
+++ b/erpnext/stock/reorder_item.py
@@ -89,12 +89,12 @@ def get_item_warehouse_projected_qty(items_to_consider):
                item_warehouse_projected_qty.setdefault(item_code, {})[warehouse] = flt(projected_qty)

                warehouse_doc = frappe.get_doc("Warehouse", warehouse)
-               
-               if warehouse_doc.parent_warehouse:
+               while warehouse_doc.parent_warehouse:
                        if not item_warehouse_projected_qty.get(item_code, {}).get(warehouse_doc.parent_warehouse):
                                item_warehouse_projected_qty.setdefault(item_code, {})[warehouse_doc.parent_warehouse] = flt(projected_qty)
                        else:
                                item_warehouse_projected_qty[item_code][warehouse_doc.parent_warehouse] += flt(projected_qty)
+                       warehouse_doc = frappe.get_doc("Warehouse", warehouse_doc.parent_warehouse)

        return item_warehouse_projected_qty

-- 
2.7.4
2 Likes

Can you send a pull request?

1 Like

I’ll get to it later today

Edit: See Auto Reorder: Propagate projected_qty all the way to the root warehouse by ppd · Pull Request #10842 · frappe/erpnext · GitHub

2 Likes

@rmehta: If you’d be so kind as to look at the pull request, that’d be great