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
[FIX] mrp,stock: compute correct quantity for stock move #158166
Conversation
d1b8b66
to
f17ae54
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.
Makes sense to me
The explanations could really be more accurate:
>>>>>>
When computing the available qty, we do "qty in - qty out":
odoo/addons/stock/models/stock_move.py
Lines 1505 to 1507 in f17ae54
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:
- The result package for incoming moves:
odoo/addons/stock/models/stock_move.py
Lines 1465 to 1466 in f17ae54
def _keys_in_sorted(ml): return (ml.location_dest_id.id, ml.lot_id.id, ml.result_package_id.id, ml.owner_id.id) - The source package for the outgoing moves:
odoo/addons/stock/models/stock_move.py
Lines 1490 to 1491 in f17ae54
def _keys_out_sorted(ml): return (ml.location_id.id, ml.lot_id.id, ml.package_id.id, ml.owner_id.id)
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
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) |
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.
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) |
f17ae54
to
69d2f9e
Compare
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
69d2f9e
to
136657f
Compare
robodoo r+ |
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>
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>
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>
@mattismegevand @Whenrow this pull request has forward-port PRs awaiting action (not merged or closed): |
1 similar comment
@mattismegevand @Whenrow this pull request has forward-port PRs awaiting action (not merged or closed): |
@mattismegevand @Whenrow this pull request has forward-port PRs awaiting action (not merged or closed): |
@mattismegevand @Whenrow this pull request has forward-port PRs awaiting action (not merged or closed): |
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>
Steps to reproduce:
destination package
components
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