so this is the first time I really struggle on something and need to consult stackoverflow personally instead just grabbing information from existing threads.
I want to make a button in 2 of our views only visible to users of a specific group. In the sale.order view everything works as intended. There is similar view in the account.move model which I inherited the same way I did with the sales.order view.
This is the view thats works correctly
<odoo>
<record id="view_sale_order_form_extension" model="ir.ui.view">
<field name="name">sale.order.form.extension</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale_commission.view_order_agent_form_inherit"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='button_edit_agents'][@icon='fa-users']"
position="attributes">
<attribute name="groups">sale_commission.group_sales_agent</attribute>
</xpath>
</field>
</record>
</odoo>
And this one doesn’t
<odoo>
<record id="view_account_move_form_extension" model="ir.ui.view">
<field name="name">sale.commission.view.move.form.extension</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="sale_commission.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='button_edit_agents'][@icon='fa-users']"
position="attributes">
<attribute name="groups">sale_commission.group_sales_agent</attribute>
</xpath>
</field>
</record>
</odoo>
The button is also added via XPath through an inherited view, this is how it is implemented:
<xpath expr="//field[@name='invoice_line_ids']/tree//field[@name='price_subtotal']" position="after">
<button name="button_edit_agents" icon="fa-users" attrs="{'invisible': [ '|',('commission_free', '=', True),('any_settled', '=', True),],'column_invisible': [('parent.move_type', 'not in', ['out_invoice', 'out_refund'])]}" type="object"/>
</xpath>
It doesn’t give me any errors, when I change the name of the button in the last view it also tells me that I can’t find the button. Also I see that the view is correctly registered as an inherited view of the view I wanted to inherit.
I am out of ideas right now, I think it must be something very simple and stupid that I can’t see or not know about. So any idea how to debug this problem further would be a great help!
Thank you guys
I tried to:
- restart the server and also the vm, so I do not have any cache problems
- trying to use a wrong button name within the xpath to check if it throws an error (it does, so it really finds the view and the button as it seems)
- using different users with different groups
- I also tried to make it invisible=1 instead just adding a group tag to check if this will work, it also doesn’t
pycal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.