For this case,Better idea to use Event/Observer.
In magento,on class Mage_Adminhtml_Block_Widget_Container
there have a function removeButton($id)
.
By using this function and with help event adminhtml_widget_container_html_before
,
You can remove cancel
button from order view
.
<adminhtml>
<events>
<adminhtml_widget_container_html_before>
<observers>
<your_module>
<class>your_module/observer</class>
<type>singleton</type>
<method>adminhtmlWidgetContainerHtmlBefore</method>
</your_module>
</observers>
</adminhtml_widget_container_html_before>
</events>
</adminhtml>
Observer:
public function adminhtmlWidgetContainerHtmlBefore($event)
{
$block = $event->getBlock();
if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
$block->removeButton('order_cancel');
}
}
You see more details at https://stackoverflow.com/a/25565340/2940291
[Edit:]
remove cancel from order grid
use core_block_abstract_prepare_layout_before
<!-- another events may which remove button from grid -->
<adminhtml>
<events>
<core_block_abstract_prepare_layout_before>
<observers>
<remove_cancel_from_grid>
<type>singleton</type>
<class>your_model/observerr</class>
<method>removeButtoncancel</method>
</remove_cancel_from_grid>
</observers>
</core_block_abstract_prepare_layout_before>
</events>
</adminhtml>
observer.
public function removeButtoncancel($observer)
{
$block = $observer->getEvent()->getBlock();
if(get_class($block) =='Mage_Adminhtml_Block_Widget_Grid_Massaction'
&& $block->getRequest()->getControllerName() == 'sales_order')
{
$block->removeItem('cancel_order');
}
}
As observer is not works then try with block class rewrite
Mage_Adminhtml_Block_Sales_Order_Grid.
Define rewrite in config.xml
<adminhtml>
<rewrite>
<sales_order_grid>[ModuleNameSpace]_[ModuleName]_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtm
l>
Rewrite class
<?php
class [ModuleNameSpace]_[ModuleName]_Block_Adminhtml_Sales_Order_Grid extends
Mage_Adminhtml_Block_Sales_Order_Grid{
protected function _prepareMassaction()
{
parent::_prepareMassaction();
$this->getMassactionBlock()->removeItem('cancel_order');
return $this;
}
}
Get full module:
Goto git hub