pycal
pycal

Reputation: 11

XPath doesn't take any effect without throwing any errors

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!

I tried to:

Upvotes: 1

Views: 37

Answers (0)

Related Questions