Help

4

readonly in view not working?

I tried to use attrs in <page> and <group> as follows:

NOT WORKING

<group attrs="{'readonly':[('state','=','done')]}">
    <field name="field1" />
    <field name="field2" />
    <field name="field3" />
    <field name="field4" />
</group>

but readonly does not work in page and group. instead when tried with invisible, it worked.

So, should I use readonly for field level only or is there any better method?

WORKING

<group>
    <field name="field1"  attrs="{'readonly':[('state','=','done')]}" />
    <field name="field2"  attrs="{'readonly':[('state','=','done')]}"/>
    <field name="field3"  attrs="{'readonly':[('state','=','done')]}"/>
    <field name="field4"  attrs="{'readonly':[('state','=','done')]}"/>
</group>
4 Comments
Avatar
Discard
Avatar
Sathors
-

Have you opened an issue in the odoo tracker ? Because it would be something really practical to have...

Avatar
yopi
-

Hello Atchuthan, I have the same problem with you. Did you solve it?

@yopi, no. I set those 4 fields as read-only and not in group.

Avatar
Mathieu Laflamme
-

This would be very handy indeed.

Also documentation makes no mention that "Invisible" attribute is working, but not "readonly" and "required".

https://www.odoo.com/documentation/9.0/reference/views.html#structural-components

11 Answers
0
Avatar
Mathieu Laflamme
Best Answer

This would be very handy indeed.

Also documentation makes no mention that "Invisible" attribute is working, but not "readonly" and "required".

https://www.odoo.com/documentation/9.0/reference/views.html#structural-components

Avatar
Discard
0
Avatar
Atul Kumar jain
Best Answer

I have used it in my custom module

<page string="Campaign Details">
                    <field name="outdoor" widget="outdoor" attrs="{'invisible':[('type_of_activity','=','paper_media')]}" >
                    <tree string="Out Door Activity" editable="bottom">
                        <field name="sequence_no"/>
                        <field name="product_id"/>
                        <field name="places"/>
                        <field name="duration"/>
                        <field name="width"/>
                        <field name="length"/>
                        <field name="tax_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','&lt;&gt;','purchase')]"/>
                        <field name="price"/>
                        <field name="quantity"/>
                        <field name="price_subtotal"/>
                    </tree> 
                    </field>
</page>
4 Comments
Avatar
Discard

yes, I can also use it on a single field.

I am asking how to set readonly for a group or page

also only invisible works in attrs of group and page

Avatar
Atul Kumar jain
-

i think you should have use this for readonly <group string="Data"> <field name="url" widget="url" attrs="{'readonly':[('type','=','binary')]}"/> </group>

yes but my question regards to use of attrs="{'readonly':[domain]}" in PAGE and GROUP

0
Avatar
Prakash
Best Answer

In Default Openerp Project Module attrs readonly used in the <page> tag:-

addons/project/project_view.xml

<page string="Extra Info" attrs="{'readonly':[('state','=','done')]}">
                            <group col="4">
                                <field name="priority" groups="base.group_user"/>
                                <field name="sequence"/>
                                <field name="partner_id"/>
                                <field name="state" invisible="1"/>
                                <field name="company_id" groups="base.group_multi_company" widget="selection"/>
                            </group>
                            <group>
                                <group string="Gantt View">
                                    <field name="date_start"/>
                                    <field name="date_end"/>
                                </group>
                                <group>
                                </group>
                            </group>
</page>
1 Comment
Avatar
Discard

yes, its available in code. But its not working in project_view