How to hide an option from “More” menu in Odoo 8?

2019-02-27 18:56发布

I had made a module which added an option to the dropdown of the More button of a tree view:

<record id="stock_move_2_stock_move_sw_manager_action" model="ir.actions.server">
    <field name="name">Swap moves</field>
    <field name="model_id" ref="model_stock_move"/>
    <field name="state">code</field>
    <field name="code">
action = self.open_stock_move_sw_manager_wizard(cr, user.id, context.get('active_ids', []), context=context)
    </field>
</record>
<record id="stock_move_sw_manager_option" model="ir.values">
    <field name="name">Swap moves</field>
    <field name="key2" eval="'client_action_multi'"/>
    <field name="model" eval="'stock.move'"/>
    <field name="value" eval="'ir.actions.server,%d'%stock_move_2_stock_move_sw_manager_action"/>
</record>

But now, I have to hide (or delete) it. Due to several reasons, to do it properly, I have to create other module to achieve this (instead of removing the original code to make it disappear).

The problem is that I am not able to make it invisible, I tried with the groups_id trick, with <delete> tag (which is dangerous in spite of being inside a <data noupdate="1"> tag) with no success.

Can anyone help me please?

Note: I would rather not to overwrite open_stock_move_sw_manager_wizard method to put there a raise Warning (that way the functionality of the option would be disabled but the option would be still visible).

标签: xml odoo-8 odoo
1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-02-27 19:24

Well, I found a way I have ever seen in any forum, so I do not know if this is crazy but it does not seem to be dangerous for the database, and there is no need of using JavaScript. I knew that the key2 indicates where to put your option, client_action_multi was for showing it inside More button dropdown, client_print_multi for showing it inside Print button dropdown, etc... so I tried to put an empty string for this column, next way:

<record id="my_inherited_module.stock_move_sw_manager_option" model="ir.values">
    <field name="key2" eval="''"/>
</record>

And by the moment it is working as expected.

查看更多
登录 后发表回答