-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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: incorrect quantity in the past #168456
[FIX] stock: incorrect quantity in the past #168456
Conversation
addons/stock/models/product.py
Outdated
moves_in_res_past = {product.id: product_qty for product, product_qty in MoveLine._read_group(domain_move_in_done, ['product_id'], ['quantity:sum'])} | ||
moves_out_res_past = {product.id: product_qty for product, product_qty in MoveLine._read_group(domain_move_out_done, ['product_id'], ['quantity:sum'])} |
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.
moves_in_res_past = {product.id: product_qty for product, product_qty in MoveLine._read_group(domain_move_in_done, ['product_id'], ['quantity:sum'])} | |
moves_out_res_past = {product.id: product_qty for product, product_qty in MoveLine._read_group(domain_move_out_done, ['product_id'], ['quantity:sum'])} | |
moves_in_res_past = {product.id: product_qty for product, product_qty in Move._read_group(domain_move_in_done, ['product_id'], ['quantity:sum'])} | |
moves_out_res_past = {product.id: product_qty for product, product_qty in Move._read_group(domain_move_out_done, ['product_id'], ['quantity:sum'])} |
Why not use the quantity
field from moves directly?
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.
That should work in theory, but the location might not be the same on the move and the move line.
The move line should have a child location of the move, but there are no restriction on the usage of the child location; You can make a move line with 5 qty in WH/Stock and another 5 qty in WH/Stock/Scrap in the same stock move.
It's not the best workflow, but I've seen some users do weird stuff like that before.
Actually, this config might not even work properly, quants on hands include WH/Stock/Scrap. So we could consider using the move directly, as it should work in most cases.
5c97271
to
5acb12d
Compare
Steps to reproduce: 1. Create a storable product and set the quantity on hand to 100 units 2. Create a delivery of 20 units and mark as to-do 3. In the detailed operations, change the quantity to 10 units 4. Validate the transfer without backorder 5. Go to Inventory > Reporting > Locations 6. Click on Inventory at Date, and select a date one month in the past 7. The on hand quantity for the product is 10 Before this commit: When viewing a product's quantity in the past, the value was based on the `product_qty` of the done stock moves. However, this is the demand, and it is not always equals to the quantity that moved. After this commit: Use the quantity of the done stock move, which reflect better what really moved in the past. opw-3946354
5acb12d
to
d7a35db
Compare
Thanks! |
Steps to reproduce: 1. Create a storable product and set the quantity on hand to 100 units 2. Create a delivery of 20 units and mark as to-do 3. In the detailed operations, change the quantity to 10 units 4. Validate the transfer without backorder 5. Go to Inventory > Reporting > Locations 6. Click on Inventory at Date, and select a date one month in the past 7. The on hand quantity for the product is 10 Before this commit: When viewing a product's quantity in the past, the value was based on the `product_qty` of the done stock moves. However, this is the demand, and it is not always equals to the quantity that moved. After this commit: Use the quantity of the done stock move, which reflect better what really moved in the past. opw-3946354 closes odoo#168456 Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
Steps to reproduce: 1. Create a storable product and set the quantity on hand to 100 units 2. Create a delivery of 20 units and mark as to-do 3. In the detailed operations, change the quantity to 10 units 4. Validate the transfer without backorder 5. Go to Inventory > Reporting > Locations 6. Click on Inventory at Date, and select a date one month in the past 7. The on hand quantity for the product is 10 Before this commit: When viewing a product's quantity in the past, the value was based on the `product_qty` of the done stock moves. However, this is the demand, and it is not always equals to the quantity that moved. After this commit: Use the quantity of the done stock move, which reflect better what really moved in the past. opw-3946354 closes odoo#168456 Signed-off-by: Quentin Wolfs (quwo) <quwo@odoo.com>
Steps to reproduce:
Before this commit:
When viewing a product's quantity in the past, the value was based on the
product_qty
of the done stock moves. However, this is the demand, and it is not always equals to the quantity that moved.After this commit:
Use the quantity of the done stock move lines, which reflect better what really moved in the past.
opw-3946354