[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) <arm@odoo.com>
This commit is contained in:
Arnold Moyaux
2023-11-02 16:57:51 +00:00
committed by clesgow
parent 234590f3db
commit c4dd4470ff
+8 -1
View File
@@ -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):