Skip to content

Commit

Permalink
fix: required by date in the reorder material request (backport #44497)…
Browse files Browse the repository at this point in the history
… (#44508)

* fix: required by date in the reorder material request (#44497)

(cherry picked from commit 4001166)

# Conflicts:
#	erpnext/stock/doctype/stock_entry/test_stock_entry.py

* chore: fix conflicts

---------

Co-authored-by: rohitwaghchaure <[email protected]>
  • Loading branch information
mergify[bot] and rohitwaghchaure authored Dec 4, 2024
1 parent 2812eae commit 15e3663
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
40 changes: 40 additions & 0 deletions erpnext/stock/doctype/stock_entry/test_stock_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,46 @@ def test_auto_reorder_level(self):
mr.cancel()
mr.delete()

def test_auto_reorder_level_with_lead_time_days(self):
from erpnext.stock.reorder_item import reorder_item

item_doc = make_item(
"Test Auto Reorder Item - 002",
properties={"stock_uom": "Kg", "purchase_uom": "Nos", "is_stock_item": 1, "lead_time_days": 2},
uoms=[{"uom": "Nos", "conversion_factor": 5}],
)

if not frappe.db.exists("Item Reorder", {"parent": item_doc.name}):
item_doc.append(
"reorder_levels",
{
"warehouse_reorder_level": 0,
"warehouse_reorder_qty": 10,
"warehouse": "_Test Warehouse - _TC",
"material_request_type": "Purchase",
},
)

item_doc.save(ignore_permissions=True)

frappe.db.set_single_value("Stock Settings", "auto_indent", 1)

mr_list = reorder_item()

frappe.db.set_single_value("Stock Settings", "auto_indent", 0)
mrs = frappe.get_all(
"Material Request Item",
fields=["schedule_date"],
filters={"item_code": item_doc.name, "uom": "Nos"},
)

for mri in mrs:
self.assertEqual(getdate(mri.schedule_date), getdate(add_days(today(), 2)))

for mr in mr_list:
mr.cancel()
mr.delete()

def test_stock_entry_for_same_posting_date_and_time(self):
warehouse = "_Test Warehouse - _TC"
item_code = "Test Stock Entry For Same Posting Datetime 1"
Expand Down
2 changes: 2 additions & 0 deletions erpnext/stock/reorder_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def add_to_material_request(**kwargs):
"description": d.description,
"stock_uom": d.stock_uom,
"purchase_uom": d.purchase_uom,
"lead_time_days": d.lead_time_days,
}
),
)
Expand Down Expand Up @@ -129,6 +130,7 @@ def get_items_for_reorder() -> dict[str, list]:
item_table.brand,
item_table.variant_of,
item_table.has_variants,
item_table.lead_time_days,
)
.where(
(item_table.disabled == 0)
Expand Down

0 comments on commit 15e3663

Please sign in to comment.