From c4dd4470ffc35997f2c08894d3c82e1d3400cd81 Mon Sep 17 00:00:00 2001 From: Arnold Moyaux Date: Tue, 31 Oct 2023 16:50:15 +0100 Subject: [PATCH] [FIX] stock: allow to validate a draft When validating a draft transfer. Currently it says that we don't have quantity. So when validating a draft, set the quantity to initial demand and validate Also, if a move is created through RPC with a quantity, auto-confirm the move, regardless of its initial demand. closes odoo/odoo#140578 Signed-off-by: Arnold Moyaux (arm) --- addons/stock/models/stock_picking.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/stock/models/stock_picking.py b/addons/stock/models/stock_picking.py index c313fbdcf15..5a4fe949cfc 100644 --- a/addons/stock/models/stock_picking.py +++ b/addons/stock/models/stock_picking.py @@ -1109,6 +1109,13 @@ class Picking(models.Model): self.package_level_ids.filtered(lambda p: not p.move_ids).unlink() def button_validate(self): + draft_picking = self.filtered(lambda p: p.state == 'draft') + draft_picking.action_confirm() + for move in draft_picking.move_ids: + if float_is_zero(move.quantity, precision_rounding=move.product_uom.rounding) and\ + not float_is_zero(move.product_uom_qty, precision_rounding=move.product_uom.rounding): + move.quantity = move.product_uom_qty + # Sanity checks. if not self.env.context.get('skip_sanity_check', False): self._sanity_check() @@ -1233,7 +1240,7 @@ class Picking(models.Model): continue if any(move.additional for move in picking.move_ids): picking.action_confirm() - to_confirm = self.move_ids.filtered(lambda m: m.state == 'draft' and not m.product_uom_qty and m.quantity) + to_confirm = self.move_ids.filtered(lambda m: m.state == 'draft' and m.quantity) to_confirm._action_confirm() def _create_backorder(self):