When getting get_batch_no_data why not add the Qtd per batch to allow the user to select items with Stock available only instead of having all Batches that have no Stock (0) … This will reduce the errors on POS when the item selected has more than one batch and only one has Stock available.
I will make the changes and create a PR for your review …
Right now i have made the following changes:
POS.PY
Batch no data added Available Qty
Batch no data SQL query changed to aggregate Qty
Pos_profile moved on the return as the second
Batch no data (pos_profile) to get the default Warehouse
POS.JS
Cloned get_data_from_server to _nofreeze (freeze set to false) at the end and
Removed set_interval_for_si_sync and check_for_internet as this is called on Sync_sales_invoice
On item_validate: checks for available or enough stcok by calling actual_qty_dict and batch_no_data (batch) before processing payment. This is more for batch items with no Stock; to avoid stock errors.
On mandatory_batch_no: Returns the Batch - Available Qty so when user selects knows how many left.
Now missing to:
Items list to show Available stock if Batch by Sum batch_no_data (all item Batch) otherwise actual_qty_dict (as currently)
As i said we have many cases on POS that user 1 sells itemA 2 Qtys but user 2 did not refresh will sell the same Qty or more and when syncing problems … in which in one of my reports i mentioned that Item shows stock 20 while batch has 10 and because 20 is the one shown on POS the user will continue to sell.