Skip to content
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
2 changes: 1 addition & 1 deletion erpnext_mrp/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.5"
__version__ = "0.8.6"
18 changes: 17 additions & 1 deletion erpnext_mrp/mrp/tasks/mrp_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,26 @@ def get_forecast_coverage_status() -> dict:


def mrp_run(enqueue: bool = True):
# Guard against overlapping runs
if enqueue and _finalise_jobs_in_progress():
frappe.logger("mrp_run").warning(
"Skipping MRP run: a previous run's finalise jobs are still in progress."
)
return
_publish_mrp_run_started()
create_mrp_item_entries()
process_mrp_item_entries(enqueue=enqueue)


def _finalise_jobs_in_progress() -> bool:
"""True if any _finalise_item_batch job from a previous run is still queued or running."""
return any(
j.status in ("queued", "started")
for j in _get_batch_jobs()
if j.job_name == "erpnext_mrp.mrp.tasks.mrp_run._finalise_item_batch"
)


def create_mrp_item_entries():
"""
Calculate BOM levels and create MRP Entry records for each item for each week in a look-ahead period.
Expand Down Expand Up @@ -774,6 +789,7 @@ def _calculate_suggested_receipts_batch(
(entry.on_hand_inventory_no_action or 0) - demand + (entry.scheduled_receipts or 0)
)

# Use save() here so the row's metadata (modified/modified_by) and fetch_from fields materialise
for entry in mrp_entry_docs:
entry.save()

Expand Down Expand Up @@ -1021,7 +1037,7 @@ def _finalise_item_batch(
entry.total_payable = (entry.suggested_orders_value_payable or 0) + (
entry.scheduled_receipts_value_payable or 0
)
entry.save()
entry.db_update()

if total_batches > 1:
try:
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "erpnext-mrp-ui",
"private": true,
"version": "0.8.5",
"version": "0.8.6",
"type": "module",
"scripts": {
"dev": "vite --host",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "erpnext_mrp",
"version": "0.8.5",
"version": "0.8.6",
"author": "Starktail (Pty) Ltd <support@starktail.com>",
"workspaces": [
"frontend",
Expand Down
Loading