Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: required by date in the reorder material request (backport #44497) (backport #44508) #44535

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading