0
votes

I have following QWeb element:

<record id="extended_res_partner" model="ir.ui.view">
    <field name="name">Extended View</field>
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="model">res.partner</field>
    <field name="arch" type="xml">
            <notebook position="inside">
                <page string="Foo" name="foo" attrs="{'invisible': [('is_customer', '=', False),]}">
                    <field name="is_customer" invisible="1"/>
                    <span>Foo2</span>
                </page>
            </notebook>
    </field>
</record>

But it does not work. I get:

Field `is_customer` does not exist

If I remove attrs=... it works fine.

1

1 Answers

1
votes

Even that you didn't provide the error message but this will work only if the the form view if for res.partner but i'm assuming that the form is for another model that have a many2one relation with res.partner in this case you need to create a related field in the model.

partner_id = ......
is_customer = fields.Boolean(related='partner_id.is_customer', readonly=True)

Then you need to add this field to the form view because attrs is client side feature it need the value in form in order to work.

<page string="foo" name="foo" attrs="{'invisible': [('is_customer', '=', False),]}"> 
    <field name="is_customer" invisible="1"/>
    <span>Foo2</span>
</page>

Note: if the form view is for res.partner just add the field to the form view because as I said is a client side operation it will not call the server to know what is the value of that field you need to pass it.