Bug fix for daily stocktake check (#5455)

- Was not recording attempts against the right internal variable
- Update to use existing functionality
This commit is contained in:
Oliver 2023-08-16 16:20:20 +10:00 committed by GitHub
parent c796e79cf0
commit 481ae0fc76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -98,7 +98,6 @@ def perform_stocktake(target: part.models.Part, user: User, note: str = '', comm
entry_cost_min = convert_money(entry_cost_min, base_currency) * entry.quantity
entry_cost_max = convert_money(entry_cost_max, base_currency) * entry.quantity
except Exception:
logger.warning(f"Could not convert {entry.purchase_price} to {base_currency}")
entry_cost_min = Money(0, base_currency)
entry_cost_max = Money(0, base_currency)

View File

@ -18,7 +18,8 @@ import InvenTree.helpers_model
import InvenTree.tasks
import part.models
import part.stocktake
from InvenTree.tasks import ScheduledTask, check_daily_holdoff, scheduled_task
from InvenTree.tasks import (ScheduledTask, check_daily_holdoff,
record_task_success, scheduled_task)
logger = logging.getLogger("inventree")
@ -167,7 +168,7 @@ def scheduled_stocktake_reports():
logger.info("Stocktake auto reports are disabled, exiting")
return
if not check_daily_holdoff('_STOCKTAKE_RECENT_REPORT', report_n_days):
if not check_daily_holdoff('STOCKTAKE_RECENT_REPORT', report_n_days):
logger.info("Stocktake report was recently generated - exiting")
return
@ -175,7 +176,7 @@ def scheduled_stocktake_reports():
part.stocktake.generate_stocktake_report(update_parts=True)
# Record the date of this report
common.models.InvenTreeSetting.set_setting('_STOCKTAKE_RECENT_REPORT', datetime.now().isoformat(), None)
record_task_success('STOCKTAKE_RECENT_REPORT')
def rebuild_parameters(template_id):