[FIX] stock: multistep reciept update quantity

Steps to reproduce:
- Enable 2 step reciept in warehaouse settings

Bug1:
- Create and confirm a PO qty = 1
- Open reciept update qty to 4 and validate
- The internal transfer qty is updated to 3 (the difference)

Bug2:
- In inventory overview create a new reciept and mark it as todo
- Update quantity and validate
- Internal transfer is not updated

Root cause:
Initially in version 17 product_uom_qty was changed to indicate the demand
before the move is done and it indicates the acutual done qty when
the move is done.
After https://github.com/odoo/odoo/pull/130342
product_uom_qty will always indicate the demand qty,
and qty_done will always indicate actually done quantity.

Fix:
updating the quantity will create a new move for the difference that is
used to trigger new push rule and then merged back in the original
when merging product_uom_qty is not updated to keep track of the intial
demand but pending linked moves should be updated to reflect the new quantity

opw-3708740

closes odoo/odoo#156331

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
Walid
2024-03-15 13:04:47 +00:00
parent c07a0d2193
commit 3d5d5cc041
2 changed files with 25 additions and 1 deletions
+2 -1
View File
@@ -1020,7 +1020,8 @@ Please change the quantity done or the rounding precision of your unit of measur
# link all move lines to record 0 (the one we will keep).
moves.mapped('move_line_ids').write({'move_id': moves[0].id})
# merge move data
moves[0].write(moves._merge_moves_fields())
merge_extra = self.env.context.get('merge_extra') and bool(merge_into)
moves[0].write(moves.with_context(merge_extra=merge_extra)._merge_moves_fields())
# update merged moves dicts
moves_to_unlink |= moves[1:]
merged_moves |= moves[0]
+23
View File
@@ -649,6 +649,29 @@ class StockMove(TransactionCase):
quants = self.gather_relevant(self.product_serial, self.stock_location)
self.assertEqual(len(quants), 0)
def test_multi_step_update(self):
"""
multi step reciept update done quantity
"""
warehouse = self.env['stock.warehouse'].search([('company_id', '=', self.env.company.id)], limit=1)
warehouse.reception_steps = 'two_steps'
move_input = self.env['stock.move'].create({
'name': self.product.name,
'location_id': self.supplier_location.id,
'location_dest_id': warehouse.wh_input_stock_loc_id.id,
'product_id': self.product.id,
'product_uom': self.uom_unit.id,
'product_uom_qty': 1.0,
'warehouse_id': warehouse.id,
})
move_input._action_confirm()
move_input.move_line_ids.quantity = 9
move_input.picked = True
move_input._action_done()
self.assertEqual(move_input.move_dest_ids.product_uom_qty, 9)
def test_mixed_tracking_reservation_8(self):
""" Send one product tracked by lot to a customer. In your stock, there are one tracked and
one untracked quant. Reserve the move, then edit the lot to one not present in stock. The