Search code examples
pythonxmlodoo

how to hide odoo action type buttons that have no name attributes?


I'm trying to hide replenish button in product form and make it visible for a specific group here is the button definition

<button string="Replenish" type="action"
                        name="%(action_product_replenish)d"
                        context="{'default_product_tmpl_id': id}"
                        groups="stock.group_stock_user"
                        attrs="{'invisible': [('type', '!=', 'product')]}"/>  

I used xbath to add change the group attribute as below

<xpath expr="//button[@name='%(action_product_replenish)d']" position="attributes">
                <attribute name="groups">stock.group_stock_manager</attribute>
</xpath>

but I get this error

raise ValueError('External ID not found in the system: %s' % xmlid) how can I do it dears ?


Solution

  • I think you are almost correct. Try prepending module name. For e.g. in expr, use //button[@name='%(<module_name>.action_product_replenish)d'] instead.

    As a side note, as @Dipen Shah said, you may want to use attributes instead of replace since the latter will remove other already defined attributes.