-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
[14.0] stock_available_to_promise_release: Allow unrelease processed qties #971
base: 14.0
Are you sure you want to change the base?
Conversation
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.
Need to adapt README as well
iterator = move._get_chained_moves_iterator("move_orig_ids") | ||
moves_to_cancel = self.env["stock.move"] | ||
# backup procure_method as when you don't propagate cancel, the | ||
# destination move is forced to make_to_stock | ||
procure_method = move.procure_method | ||
next(iterator) # skip the current move | ||
for origin_moves in iterator: | ||
done_moves = origin_moves.filtered(lambda m: m.state == "done") | ||
origin_moves = origin_moves.filtered( |
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.
When calling _split_origins
, you need to give the remaining quantity that needs to be split
move._split_origins(origin_moves, qty_to_unrelease)
def _split_origins(self, origins, qty):
qty = self.product_qty
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.
You want me to modify the implementation of _split_origins
?
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.
there is no choice since you may decrease the quantity on each iteration
qty_to_return_at_step -= returned_qty | ||
if qty_to_return_at_step == 0: | ||
break | ||
|
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.
and do this outside of for loop
qty_to_unrelease = qty_cancelled_at_step
|
||
returned_quantity = 0 | ||
# create return | ||
return_type = picking.picking_type_id.return_picking_type_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.
nice to have: raise error if no return_type configured
return_type = picking.picking_type_id.return_picking_type_id | ||
wiz_values = { | ||
"picking_id": picking.id, | ||
"original_location_id": picking.location_dest_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 is not necessary. Otherwise, it should be
"original_location_id": picking.location_dest_id.id, | |
"original_location_id": picking.location_id.id, |
"move_id": move.id, | ||
} | ||
product_return_moves.append((0, 0, return_move_vals)) | ||
returned_quantity += move_qty |
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.
The quantity_to_return
should decrease on each iteration
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.
Well, it's done in upper method
https://github.com/OCA/wms/pull/971/files#diff-fca2e9865c2d75a9793dbe699bffdf976606d996b69d09cacd25660f2926e998R693
Thing is that it's not nice to modify an argument inside a method, which is why I'm adding a new variable returned_qty
which I compare with arg.
In the end, I return the number of units that were returned, and deduct this number in the wrapping method.
This is where the quantity_to_return
counter is.
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.
Yes but I mean this line move_qty = min(quantity_to_return, move.quantity_done)
you forgot to substract the already processed qty by previous iterations. Should be move_qty = min(quantity_to_return - returned_quantity, move.quantity_done)
This PR adds a new option on stock routes, allowing to unrelease a delivery even if some internal operations (e.g. pick) are already done, creating a return move to the stock location.