Skip to content
Permalink
Browse files

[REM] mrp: remove _decrease_reserved_quanity

As `_do_unreserve` was rewrited, the `_decrease_reserved_quanity` method
isn't useful since its purpose was to avoid to unlink all stock moves
and it is what `_do_unreserve` cares about.

See fe5f3eb
  • Loading branch information
svs-odoo committed Jan 10, 2020
1 parent ee6b04f commit 19dc0cdfa3631cb284a76b3e48be710a2a3e5eca
Showing with 1 addition and 21 deletions.
  1. +1 −3 addons/mrp/models/mrp_production.py
  2. +0 −18 addons/mrp/models/stock_move.py
@@ -654,9 +654,7 @@ def _update_raw_move(self, bom_line, line_data):
old_qty = move[0].product_uom_qty
remaining_qty = move[0].raw_material_production_id.product_qty - move[0].raw_material_production_id.qty_produced
if quantity > 0:
move[0]._decrease_reserved_quanity(quantity)
move[0].with_context(do_not_unreserve=True).write({'product_uom_qty': quantity})
move[0]._recompute_state()
move[0].write({'product_uom_qty': quantity})
move[0]._action_assign()
move[0].unit_factor = remaining_qty and (quantity - move[0].quantity_done) / remaining_qty or 1.0
return move[0], old_qty, quantity
@@ -206,24 +206,6 @@ def _action_cancel(self):
production._action_cancel()
return res

def _decrease_reserved_quanity(self, quantity):
""" Decrease the reservation on move lines but keeps the
all other data.
"""
move_line_to_unlink = self.env['stock.move.line']
for move in self:
reserved_quantity = quantity
for move_line in self.move_line_ids:
if move_line.product_uom_qty > reserved_quantity:
move_line.product_uom_qty = reserved_quantity
else:
move_line.product_uom_qty = 0
reserved_quantity -= move_line.product_uom_qty
if not move_line.product_uom_qty and not move_line.qty_done:
move_line_to_unlink |= move_line
move_line_to_unlink.unlink()
return True

def _prepare_phantom_move_values(self, bom_line, product_qty, quantity_done):
return {
'picking_id': self.picking_id.id if self.picking_id else False,

0 comments on commit 19dc0cd

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