From a4059804cc766c98d9f7d55af2fbb27013c5b3dc Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 25 Oct 2018 08:21:24 +0000 Subject: [PATCH] [FIX] stock: run scheduler on partially available moves 1. Product A - on stock 5 pcs. 2. SO - 7 pcs. of A 3. Generated picking has reserved 5 pcs. 4. Increase stock to 7 pcs. (Update qty on Hand) 5. Run procurement scheduler 6. Picking still has reserved 5 pcs. The scheduler should take into account the moves partially available. Fixes #27874 opw-1895622 closes odoo/odoo#28136 --- addons/stock/models/procurement.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/procurement.py b/addons/stock/models/procurement.py index 405c4f4c318..60669789933 100644 --- a/addons/stock/models/procurement.py +++ b/addons/stock/models/procurement.py @@ -237,8 +237,10 @@ class ProcurementGroup(models.Model): self.sudo()._procure_orderpoint_confirm(use_new_cursor=use_new_cursor, company_id=company_id) # Search all confirmed stock_moves and try to assign them - confirmed_moves = self.env['stock.move'].search([('state', '=', 'confirmed'), ('product_uom_qty', '!=', 0.0)], limit=None, order='priority desc, date_expected asc') - for moves_chunk in split_every(100, confirmed_moves.ids): + moves_to_assign = self.env['stock.move'].search([ + ('state', 'in', ['confirmed', 'partially_available']), ('product_uom_qty', '!=', 0.0) + ], limit=None, order='priority desc, date_expected asc') + for moves_chunk in split_every(100, moves_to_assign.ids): self.env['stock.move'].browse(moves_chunk)._action_assign() if use_new_cursor: self._cr.commit()