From 1f00ffb0f2762fa3d21dca9188e43d68bbf7ea7a Mon Sep 17 00:00:00 2001 From: Nicolas Pierre Date: Thu, 21 Oct 2021 12:33:13 +0000 Subject: [PATCH] [FIX] stock: inventory adjustments fixes - When locations are activated, fix not being able to add a quant for tracked products just after creating one from the 'update quantity' window due to Inventory Adjustment location being auto-selected [since it is the last quant] - Fix quant not properly making fields invisible after confirming from the stock track confirmation window closes odoo/odoo#79338 Pr: https://github.com/odoo/odoo/pull/78768 Task-id: 2674732 X-original-commit: ff26704e7afaa537530c0e092a88b73ee791775f Signed-off-by: Tiffany Chang Signed-off-by: npi-odoo --- addons/stock/models/stock_quant.py | 5 +++-- addons/stock/wizard/stock_track_confirmation.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/stock/models/stock_quant.py b/addons/stock/models/stock_quant.py index 5645493bbea..b9ab8357f9f 100644 --- a/addons/stock/models/stock_quant.py +++ b/addons/stock/models/stock_quant.py @@ -557,8 +557,9 @@ class StockQuant(models.Model): if self.location_id: return if self.product_id.tracking in ['lot', 'serial']: - previous_quants = self.env['stock.quant'].search( - [('product_id', '=', self.product_id.id)], limit=1, order='create_date desc') + previous_quants = self.env['stock.quant'].search([ + ('product_id', '=', self.product_id.id), + ('location_id.usage', 'in', ['internal', 'transit'])], limit=1, order='create_date desc') if previous_quants: self.location_id = previous_quants.location_id if not self.location_id: diff --git a/addons/stock/wizard/stock_track_confirmation.py b/addons/stock/wizard/stock_track_confirmation.py index 991242148fe..cd93c999781 100644 --- a/addons/stock/wizard/stock_track_confirmation.py +++ b/addons/stock/wizard/stock_track_confirmation.py @@ -13,8 +13,8 @@ class StockTrackConfirmation(models.TransientModel): product_ids = fields.Many2many('product.product', string='Products') def action_confirm(self): - for confirmation in self: - confirmation.quant_ids._apply_inventory() + self.quant_ids._apply_inventory() + self.quant_ids.inventory_quantity_set = False @api.onchange('product_ids') def _onchange_quants(self):