Lifecycle of an operation¶
An operation does not act on the stock at the moment you write it. It goes through three states, and each one grants rights the previous did not have and withdraws freedoms the next will not have.
The three states¶
| Status | What it allows | What it forbids |
|---|---|---|
| Draft | Editing the header and the lines, deleting, validating | Any effect on the stock |
| Validated — listed under Operations to perform | Executing | Editing the header, validating again |
| Executed | Viewing, cancelling through a return operation | Editing, deleting, executing again |
The module knows a fourth status, Cancelled, inherited from the former model. In practice an executed operation is never demoted: its cancellation takes the shape of a counter-operation, described below.
Draft¶
The draft is the only moment when the operation still belongs to you. That is where the partner, the source document, the planned date, the source location, the destination location and the item lines are decided. Any attempt to edit after the draft is refused.
Locations are checked as soon as you save, not at execution time: the source must differ from the destination, a parent location can serve neither as source nor as destination, and the source/destination pair must respect the category of the operation type — virtual to internal for an entry, internal to internal for a transfer, internal to virtual for an exit.
A draft is deleted freely. An executed operation, never.
Validation¶
Validating moves no stock. It is a statement: the operation is ready, what remains to be done is physical. The module checks that at least one of the two locations is internal — an operation that neither enters nor leaves your premises would have nothing to record — then flips the status.
An operation already validated can no longer be validated, nor edited.
Execution¶
Execution is the only moment when the stock changes. It is possible only on a validated operation, and for every item line it:
- records one or several stock movements, with their quantity, their cost, their real location of departure and arrival, and their author;
- creates a batch if the operation is an entry, or consumes the existing batches if it is an exit or a transfer, following the rules described in Batches and movements;
- updates the available quantity of the item in the locations concerned, and the average cost of the item if it is an entry.
An exit that would ask for more than the available stock is refused as a whole: nothing is written halfway.
An execution cannot be undone
An executed operation is no longer edited and no longer deleted. It has left movements behind, and those movements are the memory of the stock. The only way back is to write the opposite.
Cancelling through a counter-operation¶
Cancelling an operation means creating a second one that reverses it. The module refuses as long as three conditions are not met:
- the operation to cancel is executed — a draft is deleted, not cancelled;
- its operation type declares a return type;
- no cancellation already exists for it.
The counter-operation then takes over the same partner and the same lines, with the source and the destination swapped, the original batches and the original costs. It is validated and executed straight away, and stays attached to the operation it cancels. Both documents remain: the history is not erased, it is completed.
Cancelling a single batch
A whole reception is not always at fault. A received batch may be sent back on its own, provided nothing has been consumed from it; the rest of the reception stays in stock. See Batches and movements.
The refusals met at every step carry a stable code, listed in Error codes.
Changelog¶
- 1.0 (August 18, 2026): document created.