简体   繁体   中英

[8.0]How to set all fields in form view to read-only after setting state to confirmed

I need to know what command to add to the transition of DRAFT > CONFIRMED state of a document in ODOO-8 to make all fields READ ONLY. I've attached an image below to see the fields that can be edited even though the state is confirmed.

I'm new to STACKOVERFLOW, thanks alot and i await replies

在此处输入图片说明

You should add the attrs attribute to each field in the view definition like this:

<field name="field_name" attrs="{'readonly': [('state', '=', 'confirmed')]}"/>

Or, as @CZoellner said, you can do that in the .py:

field_x = fields.Char(string="X", states={'confirmed': [('readonly', True)]})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM