Reservation on POS

Rationale

Some businesses are using POS, but they do not always have the products on hand. For example, it is frequent in pharmacies that they are missing some drugs from a prescription, but they will order them from the supplier for the afternoon or the next day.
Such businesses need a way to reserve those products (to be supplied) and keep track of them to finish the sale later.

Proposal

In a new module sale_point_reservation:

  • on sale, we add a Float field quantity_on_hold which stores the quantity not delivered.
  • a state ‘On Hold’ is added between “Open” and “Done” (available only if there is some quantity on hold). It sets a number to the sale and creates draft stock moves for the lines (which are deleted if reset to “Open” or cancel).
  • a wizard is added to the line to decrease the quantity_on_hold of the delivered or not delivered quantity. And the reservation stock move is updated accordingly.
  • the amount_to_pay does not include the quantity on hold.
  • the sale is forbidden to go to “Done” until all the quantity on hold is delivered.
  • a delay is configured and a deadline is set to keep the reservation. A scheduled task removes the reservation when it is passed.

Implementation

Here is the proposal Add sale point reservation (!3701) · Merge requests · Tryton / Tryton · GitLab

I decide to create the moves as assigned to prevent modification/deletion.

I also added a “Cancel Hold” button which remove the quantities on hold.

I used a wizard on the sale that loops over the lines with quantity on hold because we need the sale to be reloaded after.

The reservation stock move is for the total quantity so there is no need to update. It uses the total quantity because we want to book the quantities already sold to trigger a correct stock supply recalculation.

Instead I use a “Has Reservation” Function field to avoid mixing concepts and let the salesman decide how much payment is needed for the reservation.