'Recompute the state of moves given because their reserved quants were used to fulfill another operation'

def recalculate_move_state(self):

    for move in self:
        vals = {}
        reserved_quant_ids = move.reserved_quant_ids
        if ((len(reserved_quant_ids) > 0) and (not move.partially_available)):
            vals['partially_available'] = True
        if ((len(reserved_quant_ids) == 0) and move.partially_available):
            vals['partially_available'] = False
        if (move.state == 'assigned'):
            if ((move.procure_method == 'make_to_order') or move.find_move_ancestors()):
                vals['state'] = 'waiting'
            else:
                vals['state'] = 'confirmed'
        if vals:
            move.write(vals)
