# Copyright 2026 Criptomart # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models from odoo.tools import float_is_zero class StockPicking(models.Model): _inherit = "stock.picking" def _pre_action_done_hook(self): """Validate every line holding a quantity, picked by hand or not. Core only auto-picks a transfer when *no* move is picked yet, so as soon as an operator freezes one weighed line the untouched ones would be pushed to a backorder -- or cancelled, if the user answers "no backorder" -- even though their goods are in the basket. Picking everything that carries a quantity keeps the behaviour operators know. """ for picking in self.filtered(lambda p: p.state not in ("done", "cancel")): moves = picking.move_ids.filtered( lambda move: not move.picked and not move.scrapped and move.state not in ("done", "cancel") and not float_is_zero( move.quantity, precision_rounding=move.product_uom.rounding ) ) if moves: moves.picked = True return super()._pre_action_done_hook()