[FIX] stock: default quantity to return
The code was wrongly always taking the reserved quantity on the already returned moves, but if they're done their value is zero. task-2291973 closes odoo/odoo#54807 X-original-commit: 7b08f0ae0a39e8f575b21e744de16264b6365704 Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
This commit is contained in:
@@ -77,11 +77,12 @@ class ReturnPicking(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def _prepare_stock_return_picking_line_vals_from_move(self, stock_move):
|
||||
quantity = stock_move.product_qty - sum(
|
||||
stock_move.move_dest_ids
|
||||
.filtered(lambda m: m.state in ['partially_available', 'assigned', 'done'])
|
||||
.mapped('move_line_ids.product_qty')
|
||||
)
|
||||
quantity = stock_move.product_qty
|
||||
for move in stock_move.move_dest_ids:
|
||||
if move.state in ('partially_available', 'assigned'):
|
||||
quantity -= sum(move.move_line_ids.mapped('product_qty'))
|
||||
elif move.state in ('done'):
|
||||
quantity -= move.product_qty
|
||||
quantity = float_round(quantity, precision_rounding=stock_move.product_uom.rounding)
|
||||
return {
|
||||
'product_id': stock_move.product_id.id,
|
||||
|
||||
Reference in New Issue
Block a user