Search code examples
odooodoo-8odoo-9odoo-view

How to hide items in the action dropdown of a form view in odoo9?


I want to hide two options from the action drop down of a from view. When I searched I saw it is added by using the act_window. How can I hide those items.

Please see this image too..

https://i.sstatic.net/tumP5.png


Solution

  • I got the answer. I deleted the original act_window record and created a new one and changed the action for the "Put Money IN" and "Take Money Out" buttons in the sheet. Following is the code,

      <delete id="point_of_sale.action_pos_box_in" model="ir.actions.act_window"/>
      <delete id="point_of_sale.action_pos_box_out" model="ir.actions.act_window"/>
    
      <record id="misc_action_pos_box_in" model="ir.actions.act_window">
           <field name="name">Put Money In</field>
           <field name="res_model">cash.box.in</field>
           <field name="view_mode">form</field>
           <field name="target">new</field>
           <field name="src_model">pos.session</field>
           <field name="key2"></field>
       </record>
    
       <record id="misc_action_pos_box_out" model="ir.actions.act_window">
           <field name="name">Take Money Out</field>
           <field name="res_model">cash.box.out</field>
           <field name="view_mode">form</field>
           <field name="target">new</field>
           <field name="src_model">pos.session</field>
           <field name="key2"></field>
       </record>
    
       <record model="ir.ui.view" id="misc_view_pos_session_form">
           <field name="name">misc.pos.session.form</field>
           <field name="model">pos.session</field>
           <field name="inherit_id" ref="point_of_sale.view_pos_session_form"/>
           <field name="arch" type="xml">
               <xpath expr="//sheet//div[@name='button_box']//button[1]" position="replace">
                   <button class="oe_stat_button" name="%(misc_action_pos_box_in)d"
                           type="action" icon="fa-level-down"
                           attrs="{'invisible': ['|', ('cash_control', '=', False), ('state', 'not in', ['opened', 'closing_control'])]}">
                       <div class="o_form_field o_stat_info">
                           <span class="o_stat_text">Put</span>
                           <span class="o_stat_text">Money In</span>
                       </div>
                   </button>
               </xpath>
               <xpath expr="//sheet//div[@name='button_box']//button[2]" position="replace">
                   <button class="oe_stat_button" name="%(misc_action_pos_box_out)d"
                           type="action" icon="fa-level-up"
                           attrs="{'invisible': ['|', ('cash_control', '=', False), ('state', 'not in', ['opened', 'closing_control'])]}">
                       <div class="o_form_field o_stat_info">
                           <span class="o_stat_text">Take</span>
                           <span class="o_stat_text">Money Out</span>
                       </div>
                   </button>
               </xpath>
           </field>
       </record>