Skip to Content
Menu
This question has been flagged
2 Replies
1366 Views

Hello Everyone

I am trying to hide a column in account move line depending on a condition, but rather than being invisible it only makes it readonly

here is my XML code


i also tried using column_invisible but it gives me this error

Error: for modifier "column_invisible": Cannot read properties of undefined (reading 'split')


this is my py code for the field calculation

fixed_assets_user_type_name = fields.Boolean(string='User Type Name', compute='_compute_user_type_name', store=True, default=False)
@api.onchange('account_id') def _compute_user_type_name(self): for record in self: if record.account_id.user_type_id.name == 'Fixed Assets': record.fixed_assets_user_type_name = True

Avatar
Discard
Best Answer

Hi,

To address the issue, you can use the attrs attribute to conditionally set the readonly property based on the value of fixed_assets_user_type_name. Here's an example of how you can modify your XML code:

In this example, replace your_view_id, your.view.name, your.model, your_column_name with your actual view ID, view name, model, and the name of the column you want to hide or make readonly.

<odoo>
    <data>
        <record id="view_res_partner_form_inherit" model="ir.ui.view">
            <field name="name">res.partner.form.inherit</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <xpath expr="//page[@name='contacts']/group[@name='contact']/field[@name='function']" position="after">
                    <field name="product_ids" widget="many2many_tags" options="{'no_create': True}" context="{'default_vendor_id': id}"/>
                </xpath>
            </field>
        </record>
    </data>
</odoo>


Hope it helps

Avatar
Discard
Author Best Answer
                                                                                            


Avatar
Discard
Related Posts Replies Views Activity
1
May 19
4863
1
Dec 22
5576
0
Sep 22
2811
2
Mar 19
4423
1
Aug 25
582