-
-
Notifications
You must be signed in to change notification settings - Fork 730
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
[16.0][FIX] stock_reserve_rule: Don't select negative quants #2229
base: 16.0
Are you sure you want to change the base?
Conversation
The conditions to reproduce the problem are: - A demand of a X quantity - A positive quant with a big quantity > X (recent) - A positive quant with a little quantity > X but with all quantities reserved - A negative quant of a quantity < 0 and abs(quantity) < X The move reservation should lead to one move line creation
@sebalix Issue occurs when quants merge is disabled |
# Don't take into account those quants as that can lead | ||
# to a negative demand in the created move line | ||
# Mimic odoo behavior in move _action_assign() method. | ||
if location_quantity <= 0: |
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.
What about using float_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.
I thought about that. I don't know why Odoo does not use it.
https://github.com/odoo/odoo/blob/16.0/addons/stock/models/stock_move.py#L1702
Not only. If quantities are forced, negative quants can occur. |
# Create it without inventory mode as it could merge it with the other one | ||
self.env["stock.quant"].with_context(inventory_mode=True).create( |
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.
It says it creates a quant without inventory mode while setting inventory_mode=True
in the context?
The conditions to reproduce the problem are:
- A demand of a X quantity
- A positive quant (old) with a big quantity > X
- A positive quant with a little quantity > X but with all quantities reserved
- A negative quant (recent) of a quantity < 0 and abs(quantity) < X
The move reservation should lead to one move line creation