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] mrp,stock: compute correct quantity for stock move #158166

Conversation

mattismegevand
Copy link
Contributor

@mattismegevand mattismegevand commented Mar 19, 2024

Steps to reproduce:

  • Install MRP
  • Enable packages and multi-step routes
  • Enable two steps manufacturing
  • Create a component and a product
  • Create a BOM for the product and add the component
  • Make an MO for 100 units of the product
  • Go to the picking and make a move of 20 units of the component with a
    destination package
  • Put in pack
  • Create the backorder and validate the transfer of the remaining
    components
  • Go back to the MO

Issues:
Units reserved is wrong. The problem is when we are unpacking, we were
using result package inside the key. But what we want is to remove
quantity from the package the quantity originate from.

opw-3759006

@robodoo
Copy link
Contributor

robodoo commented Mar 19, 2024

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Mar 19, 2024
@mattismegevand mattismegevand force-pushed the 15.0-opw-3759006-stock_move_quantity_miscalculation-mmeg branch 3 times, most recently from d1b8b66 to f17ae54 Compare March 27, 2024 10:01
Copy link
Contributor

@adwid adwid left a comment

Choose a reason for hiding this comment

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

Makes sense to me

The explanations could really be more accurate:

>>>>>>
When computing the available qty, we do "qty in - qty out":

grouped_move_lines_in = self._get_available_move_lines_in()
grouped_move_lines_out = self._get_available_move_lines_out(assigned_moves_ids, partially_available_moves_ids)
available_move_lines = {key: grouped_move_lines_in[key] - grouped_move_lines_out.get(key, 0) for key in grouped_move_lines_in}

Where the key is a tuple with few information, among them:

Back to _action_assign, the move should be considered as an outgoing one: we are using the qty brought by the incoming moves. So, its key definition should be the same as the one of its siblings: based on the source package
<<<<<<

About the test, we try to use records of the setup as much as possible. I have added some suggestions so you can use one of the available BoMs and make the test shorter/simpler

addons/mrp/tests/test_stock.py Outdated Show resolved Hide resolved
warehouse = self.env['stock.warehouse'].search([('company_id', '=', self.env.company.id)], limit=1)
warehouse.write({'manufacture_steps': 'pbm'})

self.env['stock.quant']._update_available_quantity(component, self.stock_location, 100)
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
self.env['stock.quant']._update_available_quantity(component, self.stock_location, 100)
self.product_1.type = 'product'
self.env['stock.quant']._update_available_quantity(self.product_1, self.stock_location, 100)

addons/mrp/tests/test_stock.py Outdated Show resolved Hide resolved
@mattismegevand mattismegevand force-pushed the 15.0-opw-3759006-stock_move_quantity_miscalculation-mmeg branch from f17ae54 to 69d2f9e Compare March 28, 2024 12:13
@mattismegevand mattismegevand changed the title [FIX] stock: compute correct quantity for stock move [FIX] mrp, stock: compute correct quantity for stock move Mar 28, 2024
@mattismegevand mattismegevand changed the title [FIX] mrp, stock: compute correct quantity for stock move [FIX] mrp,stock: compute correct quantity for stock move Mar 28, 2024
Steps to reproduce:
- Install MRP
- Enable packages and multi-step routes
- Enable two steps manufacturing
- Create a component and a product
- Create a BOM for the product and add the component
- Make an MO for 100 units of the product
- Go to the picking and make a move of 20 units of the component with a
  destination package
- Put in pack
- Create the backorder and validate the transfer of the remaining
  components
- Go back to the MO

Issues:
Units reserved is wrong. The problem is when we are unpacking, we were
using result package inside the key. But what we want is to remove
quantity from the package the quantity originate from.

opw-3759006
@mattismegevand mattismegevand force-pushed the 15.0-opw-3759006-stock_move_quantity_miscalculation-mmeg branch from 69d2f9e to 136657f Compare March 28, 2024 12:14
@mattismegevand mattismegevand marked this pull request as ready for review March 28, 2024 12:14
@C3POdoo C3POdoo requested a review from a team March 28, 2024 12:19
@Whenrow
Copy link
Contributor

Whenrow commented Mar 28, 2024

robodoo r+

robodoo pushed a commit that referenced this pull request Mar 28, 2024
Steps to reproduce:
- Install MRP
- Enable packages and multi-step routes
- Enable two steps manufacturing
- Create a component and a product
- Create a BOM for the product and add the component
- Make an MO for 100 units of the product
- Go to the picking and make a move of 20 units of the component with a
  destination package
- Put in pack
- Create the backorder and validate the transfer of the remaining
  components
- Go back to the MO

Issues:
Units reserved is wrong. The problem is when we are unpacking, we were
using result package inside the key. But what we want is to remove
quantity from the package the quantity originate from.

opw-3759006

closes #158166

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
robodoo pushed a commit that referenced this pull request Mar 28, 2024
Steps to reproduce:
- Install MRP
- Enable packages and multi-step routes
- Enable two steps manufacturing
- Create a component and a product
- Create a BOM for the product and add the component
- Make an MO for 100 units of the product
- Go to the picking and make a move of 20 units of the component with a
  destination package
- Put in pack
- Create the backorder and validate the transfer of the remaining
  components
- Go back to the MO

Issues:
Units reserved is wrong. The problem is when we are unpacking, we were
using result package inside the key. But what we want is to remove
quantity from the package the quantity originate from.

opw-3759006

closes #158166

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
robodoo pushed a commit that referenced this pull request Mar 28, 2024
Steps to reproduce:
- Install MRP
- Enable packages and multi-step routes
- Enable two steps manufacturing
- Create a component and a product
- Create a BOM for the product and add the component
- Make an MO for 100 units of the product
- Go to the picking and make a move of 20 units of the component with a
  destination package
- Put in pack
- Create the backorder and validate the transfer of the remaining
  components
- Go back to the MO

Issues:
Units reserved is wrong. The problem is when we are unpacking, we were
using result package inside the key. But what we want is to remove
quantity from the package the quantity originate from.

opw-3759006

closes #158166

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
@robodoo robodoo closed this Mar 28, 2024
@fw-bot
Copy link
Contributor

fw-bot commented Apr 1, 2024

1 similar comment
@fw-bot
Copy link
Contributor

fw-bot commented Apr 2, 2024

@fw-bot
Copy link
Contributor

fw-bot commented Apr 4, 2024

@mattismegevand @Whenrow this pull request has forward-port PRs awaiting action (not merged or closed):

mega-odoo pushed a commit to odoo-dev/odoo that referenced this pull request Apr 8, 2024
Steps to reproduce:
- Install MRP
- Enable packages and multi-step routes
- Enable two steps manufacturing
- Create a component and a product
- Create a BOM for the product and add the component
- Make an MO for 100 units of the product
- Go to the picking and make a move of 20 units of the component with a
  destination package
- Put in pack
- Create the backorder and validate the transfer of the remaining
  components
- Go back to the MO

Issues:
Units reserved is wrong. The problem is when we are unpacking, we were
using result package inside the key. But what we want is to remove
quantity from the package the quantity originate from.

opw-3759006

closes odoo#158166

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
@fw-bot fw-bot deleted the 15.0-opw-3759006-stock_move_quantity_miscalculation-mmeg branch April 11, 2024 21:46
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.

None yet

6 participants