Skip to content

[18.0][FIX] barcode_stock: keep the locations of the line picked - #18

Open
szalatyzuzanna wants to merge 1 commit into
OCA:18.0from
BinhexTeam:18.0-fix-barcode_stock-line-locations
Open

szalatyzuzanna wants to merge 1 commit into
OCA:18.0from
BinhexTeam:18.0-fix-barcode_stock-line-locations

Conversation

@szalatyzuzanna

@szalatyzuzanna szalatyzuzanna commented Oct 26, 2026 •

Copy link
Copy Markdown

Follow-up of #17, raised there by @oliverg09. Every confirmation from the scanner writes the move's source and destination on the move line it fills: the move wizard does, and so does the quick re-scan of a product without lots. On a picking reserved in sublocations, validating then takes the stock from the move's location, leaving negative quants there while the shelves keep theirs, and a reception loses the shelf a putaway rule chose.

  • A line keeps the locations Odoo gave it; one is written only when the operator chooses it in the move wizard. A new line takes its move's, as Odoo does.
  • The picking's lines are read with their locations, and the move wizard shows those of the line the pick goes on (the reserved shelf, the putaway shelf), not the move's.
  • So that each line is picked where it was reserved, a move is picked line by line outside receptions, with lots or without: the wizard works on the first reserved line with something left, and a pick larger than that line holds (a GS1 count, a typed quantity) is spread over the reserved lines in turn, each up to what it holds; what is over goes on the last of them.
  • A lot the reservation does not carry (scanned, or chosen in the wizard) is reserved by Odoo itself, rather than written over another lot's reserved line: stock.move.barcode_pick_lot releases as much of the other lots' reservation as it replaces, reserves the lot under the move's source as Odoo reserves any lot (removal strategy, one line per shelf, package and owner it lies in) and marks those lines picked. Stock other moves hold is taken from where it lies, their reservation freed on validation; what is over goes on the last line. With no stock there, the wizard says so before confirming, and the server refuses it unless the operator chose where it comes from. The wizard shows where the lot lies (stock.quant.barcode_lot_location), but it is the server that decides when the operator confirms.

Tests

  • Python: where a lot lies by removal strategy (FIFO, LIFO), stock reserved for others coming last, none outside the location, without a lot or in a negative quant; a lot the reservation does not carry spread over its shelves, only what it replaces released, packaged and consigned stock (the line with its package and owner), more than the lot holds, stock another move holds (its reservation freed), a source the operator chose and a lot with no stock, each validated without negative quants.
  • HOOT: no location written unless chosen, and a chosen one written; the lines read with their locations; reserved lines filled in turn, and a pick spread over them (a reception as before), from the wizard too; a product without lots picked line by line, each from its shelf; only a chosen location sent; the location shown following the lot chosen; a reception showing and keeping its putaway shelf; a re-scan sending no location; a lot the reservation does not carry looked up and shown, then picked by the server (scanned or chosen, on a delivery too), a chosen source still winning, one with no stock there held back, confirming while the lookup is pending, and a refused pick keeping the wizard open; no other lot's line taken over outside receptions.
  • Checked on Odoo 18 by validating the resulting pickings: each shelf gives what was reserved on it, a pick of 5 over 2 + 3 included, with no negative quants; the putaway shelf is kept; a lot the reservation does not carry leaves the shelf Odoo would take it from (LIFO included), the other lot's untouched, and stock reserved for another order is left to it.

@BinhexTeam

@szalatyzuzanna
szalatyzuzanna force-pushed the 18.0-fix-barcode_stock-line-locations branch 4 times, most recently from f5bd923 to 0d43a2a Compare October 27, 2026 10:13
@szalatyzuzanna
szalatyzuzanna marked this pull request as ready for review October 27, 2026 10:47
Comment thread barcode_stock/models/stock_move.py Outdated
rounding = self.product_id.uom_id.rounding
quants = (
self.env["stock.quant"]
._gather(self.product_id, source, lot_id=lot)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvements @szalatyzuzanna !

Odoo's _gather() method accepts a qty parameter, which is used by the least_packages removal strategy to select the appropriate quants.

Could we consider passing qty=quantity here to preserve this behavior?

._gather(self.product_id, source, lot_id=lot, qty=quantity)

It would also be useful to add a test covering the least_packages removal strategy. This is a minor improvement and not a blocker for this PR.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @oliverg09! Done: the lot now comes first from the packages least_packages picks, then from the rest, as qty alone would skip the stock other moves hold. Test added.

Every confirmation from the scanner wrote the move's source and destination
on the move line it filled, so a picking reserved in sublocations took its
stock from the move's location on validation (negative quants there, the
shelves untouched), and a reception lost its putaway shelf. A line now keeps
the locations Odoo gave it unless the operator chooses another in the move
wizard, which shows the line's.

For each reserved line to be picked where it was reserved, a move is picked
line by line outside receptions, with lots or without: the wizard works on
the first reserved line with something left, and a pick is spread over the
reserved lines in turn, each up to what it holds. A lot the reservation does
not carry is taken by the server from its own quants under the move's source
(removal strategy, least packages included, stock nothing holds first, one
line per shelf, package and owner, to the destination the operator chose), as
much of the other lots' reservation as it replaces released, rather than
written over another lot's line; with no stock there, it is only picked from a
source the operator chooses.
@szalatyzuzanna
szalatyzuzanna force-pushed the 18.0-fix-barcode_stock-line-locations branch from 0d43a2a to 25cc8f6 Compare October 29, 2026 09:31
@oca-cla-bot

oca-cla-bot Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@oliverg09 oliverg09 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants