Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

How to set a field editable only for a group? In odoo9

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
fieldreadonlygroupsattributesodoo9
3 Risposte
13217 Visualizzazioni
Avatar
Baintex Technologies S.L.

In hr attendances, there is a datetime field called "name".

I want to set this field editable only for a group (or set readonly for other groups).


For example, I want to set the field "name" editable in the "tree" view for the "manager" group.


I have extended the attendance module and I have this code in the XML of my extended module:

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<record id="view_attendance_tree" model="ir.ui.view">

<field name="name">hr.attendance.tree</field>

<field name="model">hr.attendance</field>

<field name="inherit_id" ref="hr_attendance.view_attendance_who"/> 

            <field name="groups_id" eval="[(6,0,[ref('base.group_hr_manager')])]" />

<field name="arch" type="xml">

<data>

                <xpath expr="//field[@name='name']" position="attributes">

<attribute name="readonly">0</attribute>

</xpath>

    </data>

    </field>

</record>  

</data>

</openerp>


That is wrong, but more or less that's the idea.

I have tried this too:

<record id="hr_attendance.name" model="ir.ui.view">

<field name="groups_id" eval="[(3,ref('base.group_hr_user'))]"/>

</record>

It doesn't work either

What I have to modify in order to achieve this?  


Note: I checked another similar post (https://www.odoo.com/es_ES/forum/ayuda-1/question/how-to-set-a-field-readonly-for-a-employee-group-85423) but it doesn't worked for me.

1
Avatar
Abbandona
Sehrish

First get login user group: https://goo.gl/Ts3qqK

Second make a boolean field and on the basis of that field make field visible/invisible/readonly etc: https://goo.gl/BCxCpk

Avatar
Baintex Technologies S.L.
Autore Risposta migliore

I found it!

First, the field has to be defined as readonly for everyone.


<xpath expr="//field[@name='employee_id']" position="replace">     
<field name="employee_id" attrs="{'readonly':True}"/>
</xpath>


Then, we inherit the first custom view

<field name="inherit_id" ref="hr_attendance_extend.view_employee_readonly_custom"/>


Finally, we delete the readonly restriction for the administrators group (group_hr_manager)

<field name="groups_id" eval="[(6, 0, [ref('base.group_hr_manager')])]"/>
<field name="arch" type="xml">
 <xpath expr="//field[@name='employee_id']" position="attributes">
 <attribute name="readonly">False</attribute>
 </xpath>
</field


Here is the final code:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
 <data>
 <record id="view_employee_readonly_custom" model="ir.ui.view">
 <field name="name">hr.attendance.form</field>
 <field name="model">hr.attendance</field>
 <field name="inherit_id" ref="hr_attendance.view_attendance_form"/>
 <field name="arch" type="xml">
 <xpath expr="//field[@name='employee_id']" position="replace">
 <field name="employee_id" attrs="{'readonly':True}"/>
 </xpath>
 </field>
 </record>
 <record id="view_employee_readonly" model="ir.ui.view">
 <field name="name">hr.attendance.form</field>
 <field name="model">hr.attendance</field>
 <field name="inherit_id" ref="hr_attendance_extend.view_employee_readonly_custom" />
 <field name="groups_id" eval="[(6, 0, [ref('base.group_hr_manager')])]"/>
 <field name="arch" type="xml">
 <xpath expr="//field[@name='employee_id']" position="attributes">
 <attribute name="readonly">False</attribute>
 </xpath>
 </field>
 </record>
 </data>
</openerp>


2
Avatar
Abbandona
Avatar
Divyang Jariwala
Risposta migliore

Hello MouTio,

You can do with py file by fields_view_get method.

1
Avatar
Abbandona
Avatar
Ray Carnes
Risposta migliore

You need to look at the priority of the views (sequence) and define a priority field value for yours so it isn't overridden by a higher priority view.

1
Avatar
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
How to make a field readonly and not editable after save. Risolto
fields readonly attributes odoo9
Avatar
Avatar
Avatar
2
mag 21
19852
Add Unique Field Like Id
field model odoo9
Avatar
Avatar
Avatar
3
ott 16
7653
make fields as read only based on groups
fields readonly groups
Avatar
Avatar
2
set 15
5085
How to use the button attribute "args" Risolto
views button attributes odoo9
Avatar
Avatar
1
feb 25
13529
Make field readonly after save it and only user creator and administrator can edit it.
field readonly buttons OdooStudio
Avatar
Avatar
Avatar
Avatar
4
giu 24
4112
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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