How to Display Only Inventory Tab in Admin Product Edit Section

adminhtmlcatalogevent-observermagento-1.8

The Product edit section (Catalog->Manage Products -> edit) I want to display only the Inventory tab for a particular admin user role.

For instance an admin user with "test" as user role should only see Inventory tab while trying to edit a product.

Currently I use core_block_abstract_prepare_layout_after event to add a custom tab.

My observer function is as follows:

public function addTestBlock($observer){
$block = $observer->getEvent()->getBlock();
$product = Mage::registry('product');
if ($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs && $this->_canAddTab($product)){
    $block->addTab('myentity', array(
    'label' => Mage::helper('mymodule')->__('Test'),
    'url'   => Mage::helper('adminhtml')->getUrl('adminhtml/marketplace_tendor_catalog_product/tendors', array('_current' => true)),
    'class' => 'ajax',
    ));
}
return $this;

}

I have planned to use adminhtml_catalog_product_edit_prepare_form event to display only the "Inventory" tab for test admin user.

  1. Can I do this using event observer?
  2. If yes, How?

Can anyone guide me pls?

[EDIT: ]
as suggested by mpaepper I used controller_action_layout_generate_blocks_after event and my observer function was like below:

public function vendorLayout($evt){
        $tabBlock =$evt->getEvent()->getBlock('product_tabs');
        $tab_ids = $tabBlock->getTabsIds();
        foreach ($tab_ids as $tab){
            if($tab != 'inventory'){
                $tabBlock->removeTab($tab);
            }
        }
    }
  1. checking the user role is not a problem I can add it later.
  2. removing the "General" tab results in the following.
  3. If i allow "General" (group_4) and "Inventory" (inventory) tabs, then it's working fine, but the requirement is only to display Inventory tab.

enter image description here

nothing happens if I click on that tab, I think the js script isn't loading.
what am i doing wrong?

Best Answer

I used core_block_abstract_prepare_layout_after event and the observer was as follows:

public function vendorLayout($evt){ // for removing unallowed tabs and buttons from product information edit page.
        $tabBlock = $evt->getEvent()->getBlock();
        if ($tabBlock instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs) {
            $tab_ids = $tabBlock->getTabsIds();
            $tabs_to_show = array('inventory');
            foreach ($tab_ids as $tab){
                if(!in_array($tab, $tabs_to_show)){
                    $tabBlock->removeTab($tab);
                }
                else{
                    $tabBlock->setActiveTab($tab);
                }
            }
        }
        elseif($tabBlock instanceof Mage_Adminhtml_Block_Catalog_Product_Edit){
            $buttonsToBeRemoved = array('back_button', 'reset_button', 'delete_button', 'duplicate_button', 'save_and_edit_button');
            foreach($buttonsToBeRemoved as $button){
                $tabBlock->unsetChild($button);
            }
        }
    }

first condition removes all the tabs but "inventory", second condition removes all buttons but "save".

Thanks to @mpaepper and @Alex.