Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consulting
    • Accounting Firm
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Solar Energy Systems
    • Shoe Maker
    • Serveis de neteja
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Is there any way that I can make a entire form Readonly?

Subscriure's

Get notified when there's activity on this post

This question has been flagged
readonlyformviewattributeodoo11
3 Respostes
26810 Vistes
Avatar
venugopal voraganti

I know that we can make a complete form by placing the read-only attribute on each field. But my requirement is to make the complete form read-only based on status (As I have too many fields in my form view).

1
Avatar
Descartar
Avatar
Jose Gpe Osuna
Best Answer

You can set all fields to readony, using a context value and overriding the fields_view_get() method of your model

Example:

If you want to turn the entire account.invoice form to readonly, you can use the next code, using a context value:

Calling from any specific button, menu or field set a context value. I choose 'turn_view_readonly' value to True
from a the sale order view xml button.

<button name="action_view_invoice" string="View Invoice" type="object" class="oe_highlight"        
context="{'turn_view_readonly':True}"/>


And  inherit  account.invoice code model, checking for this value

from odoo import models, api
from lxml import etree
import simplejson

class AccountInvoice(models.Model):
_inherit = 'account.invoice'
@api.model
def fields_view_get(self, view_id=None, view_type=False, toolbar=False, submenu=False):
context = self._context
res = super(AccountInvoice, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar,
submenu=submenu)

if context.get('turn_view_readonly'): # Check for context value
doc = etree.XML(res['arch'])
if view_type == 'form': # Applies only for form view
for node in doc.xpath("//field"): # All the view fields to readonly
node.set('readonly', '1')
node.set('modifiers', simplejson.dumps({"readonly": True}))

res['arch'] = etree.tostring(doc)
return res

You can also look for 'active_id' or 'active_ids' value in context, and check the state field of the recordset and turn the fields to readonly..

if context.get('active_id') and self.browse(context.get('active_id')).state == 'X':
doc = etree.XML(res['arch'])
# ... etc

  

5
Avatar
Descartar
Zahid Mehmood

fields_view_get
This method only gets call when page get refresh, not when you open any record.

Avatar
Maher Khalil
Best Answer

You can make a boolean field and make a function to turn it true if status achieved then make view read only if that field is true

0
Avatar
Descartar
Avatar
Sushma
Best Answer

Hi,

Can try to add security rule, disable rights to create and edit, grant only read access. 

0
Avatar
Descartar
venugopal voraganti
Autor

Dear Sushma. Thank you for your answer. But this is not I'm looking at. I need to make readonly in a specific status for all groups.

Sushma

Hi Venu,

Indeed, but this is only way you can achieve, with group tag readonly won't work. This need to be added only to fields.

Thanks !

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
Odoo 11: readonly bypass module Solved
readonly odoo11
Avatar
Avatar
2
de juny 20
9404
How to make whole form view readonly (rather than put readonly attribute to each field)?
readonly formview
Avatar
Avatar
1
de març 18
7472
Editable tree view inside a form view is not saving.
treeview formview odoo11
Avatar
Avatar
Avatar
2
d’oct. 18
8402
How can I set all form fields readonly in Odoo 17 depending on a field?
readonly fields_view_get formview odoo17
Avatar
0
de set. 24
4291
How to Make an Entire Form View Readonly in Odoo 15? Solved
form readonly formview v15
Avatar
Avatar
Avatar
2
de juny 24
11986
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now