Skip to content

ffl_core.api.item_admin

Source: apps/ffl_core/ffl_core/api/item_admin.py · 6 endpoint(s)

Generated by make api-docs — do not edit by hand.

add_stock

POST /api/method/ffl_core.api.item_admin.add_stock

Auth (derived from code): Roles: Stock Manager / System Manager

Quick stock receipt — creates and submits a Material Receipt Stock Entry.

Used by the "+ Add Stock" button on the Item form for everyday adjustments (found inventory, opening stock, manual top-up). Firearms tracked by Serial No are rejected — those go through Receive Goods so the FFL compliance flow runs.

arg type required default description
item_code string yes — Non-serialized stock Item to receive.
qty — yes — Units to add, > 0.
warehouse string | null no None Optional target; defaults to the configured warehouse.
rate — no None Optional per-unit cost; non-numeric or <= 0 is ignored and the cost on file is used instead (never the selling price).
remarks string | null no None Optional Stock Entry remarks.

Returns: {ok, name, qty, warehouse}.

Raises: ValidationError: qty <= 0, missing item, non-stock item, serial-tracked item, no warehouse available, or no rate given and no cost on file.

Permissions: Stock Manager / System Manager.

apps/ffl_core/ffl_core/api/item_admin.py:116

force_delete

POST /api/method/ffl_core.api.item_admin.force_delete

Auth (derived from code): Roles: System Manager

DESTRUCTIVE: cancel referencing docs, drop links, delete Items outright.

Cancels referencing submitted docs, deletes referencing drafts, wipes simple linked rows (Stock Ledger, Serial No, Bin, Batch, Item Price, FFL Acquisition/Disposition), then deletes the Items. Cancelled-doc history rows are left alone — they're audit trail.

arg type required default description
item_codes — yes — A list, JSON-encoded list, or comma-separated string.
cancel_submitted bool int str no

Returns: {ok, deleted: [...], cancelled: [{doctype, name}], deleted_drafts: [{doctype, name}], simple: [{doctype, count}], errors: [...], missing: [...]} — ok is False when any per-row step errored.

Raises: ValidationError: cancel_submitted is falsy and submitted docs exist.

Permissions: System Manager only (destructive).

apps/ffl_core/ffl_core/api/item_admin.py:597

get_item_stock

POST /api/method/ffl_core.api.item_admin.get_item_stock

Auth (derived from code): Requires read permission on Item (Frappe DocType permission check).

Return {item_code: total_actual_qty} summed across all warehouses.

Reads from tabBin (the per-warehouse stock-on-hand cache). Items with no Bin row return 0. Designed for the Item list view + Item form to show a stock badge without forcing the user to open Stock Balance.

arg type required default description
item_codes — yes — A list, JSON-encoded list, or comma-separated string.

Returns: {item_code: total_actual_qty} — every requested code is present.

apps/ffl_core/ffl_core/api/item_admin.py:433

preview_delete

POST /api/method/ffl_core.api.item_admin.preview_delete

Auth (derived from code): Roles: System Manager

Preview a force_delete: per-doctype counts of rows that would be touched.

arg type required default description
item_codes — yes — A list, JSON-encoded list, or comma-separated string.

Returns: {item_codes, submitted: [{doctype, count}] (must be cancelled first), drafts: [{doctype, count}] (deleted without cancel), simple: [{doctype, count}] (direct delete), missing: [...]}.

Permissions: System Manager.

apps/ffl_core/ffl_core/api/item_admin.py:521

recompute_all_item_actual_qty

POST /api/method/ffl_core.api.item_admin.recompute_all_item_actual_qty

Auth (derived from code): Roles: System Manager

One-shot reconciliation: refresh Item.actual_qty for every Item from

current Bin sums in a single bulk UPDATE. Useful after migrate to backfill the new field, or after data imports / direct-DB tweaks.

Two statements: 1. UPDATE Item JOIN (SUM Bin) — set qty for items that have Bin rows 2. UPDATE Item — zero out items with no Bin rows (e.g. after Force Delete)

Returns: {"with_bin": }.

Permissions: System Manager.

apps/ffl_core/ffl_core/api/item_admin.py:392

set_stock

POST /api/method/ffl_core.api.item_admin.set_stock

Auth (derived from code): Roles: Stock Manager / System Manager

Adjust stock to an absolute quantity via Stock Reconciliation.

Used by the "Adjust Quantity" button on the Item form when the user wants to set on-hand to a specific number (post-physical-count, found inventory correction, write-off). For positive deltas a Material Receipt is faster (see add_stock); set_stock is the right primitive when the user already knows the absolute target.

The quantity entered is what is on the shelf now. A register sale not yet closed has left the shelf but is still in the Bin (ERPNext posts it at the register close), so the reconciliation sets the Bin to the entered quantity plus those units; once the close posts them the Bin reads the entered figure.

arg type required default description
item_code string yes — Non-serialized stock Item to adjust.
new_qty — yes — Units physically on the shelf now, >= 0.
warehouse string | null no None Optional target; defaults to the configured warehouse.
reason string | null no None Optional audit note (stored as a Comment on the Stock Reconciliation).

Returns: {ok, name (Stock Reconciliation #), prev_qty, new_qty (as entered), open_register_qty (units on register sales not closed yet), delta (what the reconciliation changed the Bin by), warehouse}.

Raises: ValidationError: Serial-tracked item, invalid qty, missing warehouse, no qty change, or a count below the units on an open register return.

Permissions: Stock Manager / System Manager.

apps/ffl_core/ffl_core/api/item_admin.py:203