Skip to content
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

Conversation

mwath
Copy link
Contributor

@mwath mwath commented Jun 7, 2024

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 lines, which reflect better what really moved in the past.

opw-3946354

@robodoo
Copy link
Contributor

robodoo commented Jun 7, 2024

Pull request status dashboard.

@C3POdoo C3POdoo requested a review from a team June 7, 2024 09:46
@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Jun 7, 2024
Comment on lines 181 to 182
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'])}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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?

Copy link
Contributor Author

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.

@mwath mwath force-pushed the 17.0-fix-stock-incorrect-past-qty-opw-3946354-wama branch from 5c97271 to 5acb12d Compare August 9, 2024 09:55
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
@mwath mwath force-pushed the 17.0-fix-stock-incorrect-past-qty-opw-3946354-wama branch from 5acb12d to d7a35db Compare August 9, 2024 09:57
@clesgow
Copy link
Contributor

clesgow commented Aug 9, 2024

Thanks!
@robodoo r+

@robodoo robodoo closed this in 513dde6 Aug 9, 2024
hsal-odoo pushed a commit to odoo-dev/odoo that referenced this pull request Aug 12, 2024
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>
Dasanchez1992 pushed a commit to Nosolotec/odoo that referenced this pull request Aug 22, 2024
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>
@fw-bot fw-bot deleted the 17.0-fix-stock-incorrect-past-qty-opw-3946354-wama branch August 23, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants