Mohamed Fouad
Mohamed Fouad

Reputation: 526

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 ?

Upvotes: 3

Views: 1767

Answers (2)

Pyae
Pyae

Reputation: 519

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.

Upvotes: 2

Dipen Shah
Dipen Shah

Reputation: 2454

If you want to add the specific group then use with an attribute on button following:

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

Or if you replace the button then you must have to re-declare that button until you are not able to replace having an error. Following code for replace:

<xpath expr="//button[@name='%(action_product_replenish)d']" position="replace">
    <!-- This way you replace it's behavior  -->
    <button string="Replenish" type="action"
        name="%(action_product_replenish)d"
        context="{'default_product_tmpl_id': id}"
        groups="Your groups"
        attrs="{'invisible': [('type', '!=', 'product')]}"/>
</xpath>

Upvotes: 0

Related Questions