Search code examples
odooodoo-14

How to hide/delete action menu in a form?


I cannot find a way to hide or delete the action menu out of the form.

action menu

I tried:

  • <delete> tag
  • replace it
  • using ir.values
  • domain

None of them work.

This is the code of the action button from the standard xml file.

<record id="action_product_template_price_list_report" model="ir.actions.server">
    <field name="name">Generate Pricelist</field>
    <field name="groups_id" eval="[(4, ref('product.group_product_pricelist'))]"/>
    <field name="model_id" ref="product.model_product_template"/>
    <field name="binding_model_id" ref="product.model_product_template"/>
    <field name="state">code</field>
    <field name="code">
ctx = env.context
ctx.update({'default_pricelist': env['product.pricelist'].search([], limit=1).id})
action = {
    'name': 'Pricelist Report',
    'type': 'ir.actions.client',
    'tag': 'generate_pricelist',
    'context': ctx,
}
    </field>
</record>

Solution

  • I don't know what some parts of this code do, but I found it and edited it to solve my issue. The action is hidden now.

    from odoo import api, models, tools
    
    class IrActionsInherit(models.Model):
        _inherit = 'ir.actions.actions'
    
        @api.model
        @tools.ormcache('frozenset(self.env.user.groups_id.ids)', 'model_name')
        def get_bindings(self, model_name):
            result = super(IrActionsInherit, self).get_bindings(model_name)
            actions = result.get('action')
            for action in actions:
                if action.get('name') == 'Generate Pricelist':
                    actions.remove(action)
                    result.update({'action': actions})
            return result