Skip to content
Permalink
Browse files

[FIX] stock: validate a picking with only scrap

Usecase:
- Create a planned transfer
- Add line with initial demand
- Create a scrap
- Click on button validate

The wizard asking for a backorder or not is diplayed. The UserError
that prevent to validate a picking without quantity done or reserved
should have been raised. The scrap moves are directly processed once
the user validates his scrap order. Validate a picking with only done
moves, will not have any effect.
  • Loading branch information...
amoyaux committed Feb 18, 2019
1 parent 56b5857 commit a7e35e6bab46711359383b73d6e488268ef469ba
Showing with 10 additions and 1 deletion.
  1. +1 −1 addons/stock/models/stock_picking.py
  2. +9 −0 addons/stock/tests/test_move.py
@@ -708,7 +708,7 @@ def button_validate(self):
# If no lots when needed, raise error
picking_type = self.picking_type_id
precision_digits = self.env['decimal.precision'].precision_get('Product Unit of Measure')
no_quantities_done = all(float_is_zero(move_line.qty_done, precision_digits=precision_digits) for move_line in self.move_line_ids)
no_quantities_done = all(float_is_zero(move_line.qty_done, precision_digits=precision_digits) for move_line in self.move_line_ids.filtered(lambda m: m.state not in ('done', 'cancel')))
no_reserved_quantities = all(float_is_zero(move_line.product_qty, precision_rounding=move_line.product_uom_id.rounding) for move_line in self.move_line_ids)
if no_reserved_quantities and no_quantities_done:
raise UserError(_('You cannot validate a transfer if you have not processed any quantity. You should rather cancel the transfer.'))
@@ -3233,6 +3233,15 @@ def test_immediate_validate_7(self):
})
picking.action_confirm()
picking.action_assign()

scrap = self.env['stock.scrap'].create({
'picking_id': picking.id,
'product_id': self.product1.id,
'product_uom_id': self.uom_unit.id,
'scrap_qty': 5.0,
})
scrap.do_scrap()

# No products are reserved on the move of 10, click on `button_validate`.
with self.assertRaises(UserError):
picking.button_validate()

0 comments on commit a7e35e6

Please sign in to comment.
You can’t perform that action at this time.