There are a number of ways to achieve this. If we're using a custom controller like in your code, you could try this:
public function action_editview()
{
/* Set view */
if (/*your condition here*/)
{
$this->view = 'noaccess';
}
else
{
$this->view = 'edit';
}
}
Hope this helps!
Ps. The reason your code would appear to create a new record seems to be due to the "$this->bean = new CustomOpportunity();" -line, where you overwrite the bean you are about to edit with a new, fresh record :-)