-
Notifications
You must be signed in to change notification settings - Fork 23.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] stock: try to reassign stolen transfer #164606
base: 15.0
Are you sure you want to change the base?
Conversation
ffff138
to
7abf4a7
Compare
Sometimes people do internal transfer to move a package inside a sub location. Use case: - Enable multi locations + packages - Create a product and put 1 unit in stock with a package PACK1 - Do a delivery (planned transfer) for this product - Create an internal transfer and move the package from WH/stock to WH/stock/shelf1 It's due to `_free_reservation` method. During the internal transfer the product is not free for usage but it exists in inventory. So it will remove the reservation from delivery and move it to the new location (+ recompute the state of reservation). However the destination location of the internal transfer could still under the delivery's source location (and could keep the reservation). We improve it by keeping in memory the move that were unreserve and we try to reverve them again after moving stuff in the internal picking WIP still need to manage it for write and create method of sml
7abf4a7
to
9eb033a
Compare
move = self.env['stock.move'].browse(vals['move_id']) | ||
vals['picking_id'] = move.picking_id.id | ||
vals['company_id'] = move.company_id.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is not related to the issue but when you create a stock.move.line with a move but not the picking. The stock.move.line
and the stock.picking
are not linked and it could result in strange error when doing picking.move_line_ids
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like this part could be part of the valid sml data commit
Usecase: - Create a product with one unit available in WH/Shelf1 - Do an internal transfer for this product from WH/Shelf1 to WH/Shelf2 - Do a delivery and reserve - Go back on the internal transfer and unlock - Modify the location_dest from Shelf2 to Shelf1 Current behavior: The delivery still reserve the piece in Shelf2 and the quant has 1unit reserve but no stock Expected behavior: The delivery has the reservation to Shelf1 and only one quant exist in Shelf1
9a2b848
to
1c971e4
Compare
It's possible to create a `stock.move.line` with both keys `picking_id` and `move_id` set but with a move not in the picking. It results in an inconcistent state
bab08a5
to
214de21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of nitpicks and I found a couple of potential bad flows with this change: https://drive.google.com/file/d/1zp9GvWmBOf-oUQzlMvTvZzT4eU9X3scy/view?usp=sharing
But otherwise it seems fine to me
moves_stolen = self.env['stock.move'] | ||
if stolen_move_ids: | ||
moves_stolen = self.env['stock.move'].browse(stolen_move_ids) | ||
moves_stolen._recompute_state() | ||
return moves_stolen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick
moves_stolen = self.env['stock.move'] | |
if stolen_move_ids: | |
moves_stolen = self.env['stock.move'].browse(stolen_move_ids) | |
moves_stolen._recompute_state() | |
return moves_stolen | |
stolen_moves = self.env['stock.move'] | |
if stolen_move_ids: | |
stolen_moves = self.env['stock.move'].browse(stolen_move_ids) | |
stolen_moves._recompute_state() | |
return stolen_moves |
@@ -971,7 +971,6 @@ def button_validate(self): | |||
for picking in self: | |||
if not picking.move_lines and not picking.move_line_ids: | |||
pickings_without_moves |= picking | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoopsies (unnecessary diff)
move = self.env['stock.move'].browse(vals['move_id']) | ||
picking = self.env['stock.picking'].browse(vals['picking_id']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move = self.env['stock.move'].browse(vals['move_id']) | |
picking = self.env['stock.picking'].browse(vals['picking_id']) | |
move = self.env['stock.move'].browse(vals['move_id']) if vals.get('move_id') else False | |
picking = self.env['stock.picking'].browse(vals['picking_id']) if vals.get('picking_id') else False |
move = self.env['stock.move'].browse(vals['move_id']) | ||
vals['picking_id'] = move.picking_id.id | ||
vals['company_id'] = move.company_id.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like this part could be part of the valid sml data commit
Sometimes people do internal transfer to move a package inside a sub location.
Use case:
It's due to
_free_reservation
method. During the internal transfer the product is not free for usage but it exists in inventory. So it will remove the reservation from delivery and move it to the new location (+ recompute the state of reservation).However the destination location of the internal transfer could still under the delivery's source location (and could keep the reservation). We improve it by keeping in memory the move that were unreserve and we try to reverve them again after moving stuff in the internal picking
WIP still need to manage it for write and create method of sml
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr