Community mailing list archives

community@mail.odoo.com

Re: Make the whole record readonly in a specific state

by
Yassine TEIMI
- 05/30/2016 06:03:01
Hi Martin, Thanks for your answer, 

On the field definition you can put something like states={'done': [('readonly', True)]}

> My status is based on a many2one field (customized) : statut_id (I need to have configurable status), so I can't use 'states'.
  I did an attrs on all fields on xml side. 

Then it's probably the view definition that is incorrect, it should work with an attrs.

> I did a group on all fields inside the form tag, like: 
              <form>

<group attrs="{'readonly': [('reporting_state', 'in', ('abandoned', 'deposed'))]}">
                       <group>
                         <!-- fields definition -->
                       </group>
                       <group>
                         <!-- fields definition -->
                       </group>
                   </group>
              </form>

Is that correct ? 


I would definitely discourage to override fields_view_get, that's probably overkill for what you are trying to achieve

> Thank you for that confirmation.

Best regards.


2016-05-30 10:12 GMT+01:00 Martin Trigaux <mat@odoo.com>:
On 30/05/16 11:07, Yassine Teimi wrote:
> I want to make all fields readonly when my model comes to a specific state.

on the field definition you can put something like

states={'done': [('readonly', True)]}

> I tried to make a group on the whole form, and add an attrs, but it
> damaged the view.

Then it's probably the view definition that is incorrect, it should work 
with an attrs.

> When I overrided *fields_view_get()*, it doesn't consider any
> attrs-readonly defined on the xml, so it's like it imposes to define all
> readonly fields on the*fields_view_get()*.

I would definitely discourage to override fields_view_get, that's 
probably overkill for what you are trying to achieve


-- 
Martin Trigaux
Odoo
https://odoo.com
https://github.com/mart-e

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe




--

Cordialement

Yassine TEIMI

Consultant & Odoo Project Manager
TEL : +212 6-87 71 41 18