Skip to Content
Odoo Meniu
  • Autentificare
  • Try it free
  • Aplicații
    Finanțe
    • Contabilitate
    • Facturare
    • Cheltuieli
    • Spreadsheet (BI)
    • Documente
    • Semn
    Vânzări
    • CRM
    • Vânzări
    • POS Shop
    • POS Restaurant
    • Abonamente
    • Închiriere
    Site-uri web
    • Constructor de site-uri
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Lanț Aprovizionare
    • Inventar
    • Producție
    • PLM
    • Achiziție
    • Maintenance
    • Calitate
    Resurse Umane
    • Angajați
    • Recrutare
    • Time Off
    • Evaluări
    • Referințe
    • Flotă
    Marketing
    • Social Marketing
    • Marketing prin email
    • SMS Marketing
    • Evenimente
    • Automatizare marketing
    • Sondaje
    Servicii
    • Proiect
    • Foi de pontaj
    • Servicii de teren
    • Centru de asistență
    • Planificare
    • Programări
    Productivitate
    • Discuss
    • Aprobări
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Aplicații Terțe Odoo Studio Platforma Odoo Cloud
  • Industrii
    Retail
    • Book Store
    • Magazin de îmbrăcăminte
    • Magazin de Mobilă
    • Magazin alimentar
    • Magazin de materiale de construcții
    • Magazin de jucării
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Distribuitor de băuturi
    • Hotel
    Proprietate imobiliara
    • Real Estate Agency
    • Firmă de Arhitectură
    • Construcție
    • Estate Managament
    • Grădinărit
    • Asociația Proprietarilor de Proprietăți
    Consultanta
    • Firma de Contabilitate
    • Partener Odoo
    • Agenție de marketing
    • Law firm
    • Atragere de talente
    • Audit & Certification
    Producție
    • Textil
    • Metal
    • Mobilier
    • Mâncare
    • Brewery
    • Cadouri corporate
    Health & Fitness
    • Club Sportiv
    • Magazin de ochelari
    • Centru de Fitness
    • Wellness Practitioners
    • Farmacie
    • Salon de coafură
    Trades
    • Handyman
    • IT Hardware and Support
    • Asigurare socială de stat
    • Cizmar
    • Servicii de curățenie
    • HVAC Services
    Altele
    • Organizație nonprofit
    • Agenție de Mediu
    • Închiriere panouri publicitare
    • Fotografie
    • Închiriere biciclete
    • Asigurare socială
    Browse all Industries
  • Comunitate
    Învăță
    • Tutorials
    • Documentație
    • Certificări
    • Instruire
    • Blog
    • Podcast
    Empower Education
    • Program Educațional
    • Scale Up! Business Game
    • Visit Odoo
    Obține Software-ul
    • Descărcare
    • Compară Edițiile
    • Lansări
    Colaborați
    • Github
    • Forum
    • Evenimente
    • Translations
    • Devino Partener
    • Services for Partners
    • Înregistrează-ți Firma de Contabilitate
    Obține Servicii
    • Găsește un Partener
    • Găsiți un contabil
    • Meet an advisor
    • Servicii de Implementare
    • Referințe ale clienților
    • Suport
    • Actualizări
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obține un demo
  • Prețuri
  • Ajutor

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

  • CRM
  • e-Commerce
  • Contabilitate
  • Inventar
  • PoS
  • Proiect
  • MRP
All apps
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
All Posts Oameni Insigne
Etichete (View all)
odoo accounting v14 pos v15
Despre acest forum
Suport

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

Abonare

Primiți o notificare când există activitate la acestă postare

Această întrebare a fost marcată
fieldreadonlygroupsattributesodoo9
3 Răspunsuri
13203 Vizualizări
Imagine profil
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
Imagine profil
Abandonează
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

Imagine profil
Baintex Technologies S.L.
Autor Cel mai bun răspuns

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
Imagine profil
Abandonează
Imagine profil
Divyang Jariwala
Cel mai bun răspuns

Hello MouTio,

You can do with py file by fields_view_get method.

1
Imagine profil
Abandonează
Imagine profil
Ray Carnes
Cel mai bun răspuns

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
Imagine profil
Abandonează
Enjoying the discussion? Don't just read, join in!

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

Înscrie-te
Related Posts Răspunsuri Vizualizări Activitate
How to make a field readonly and not editable after save. Rezolvat
fields readonly attributes odoo9
Imagine profil
Imagine profil
Imagine profil
2
mai 21
19845
Add Unique Field Like Id
field model odoo9
Imagine profil
Imagine profil
Imagine profil
3
oct. 16
7651
make fields as read only based on groups
fields readonly groups
Imagine profil
Imagine profil
2
sept. 15
5066
How to use the button attribute "args" Rezolvat
views button attributes odoo9
Imagine profil
Imagine profil
1
feb. 25
13511
Make field readonly after save it and only user creator and administrator can edit it.
field readonly buttons OdooStudio
Imagine profil
Imagine profil
Imagine profil
Imagine profil
4
iun. 24
4094
Comunitate
  • Tutorials
  • Documentație
  • Forum
Open Source
  • Descărcare
  • Github
  • Runbot
  • Translations
Servicii
  • Hosting Odoo.sh
  • Suport
  • Actualizare
  • Custom Developments
  • Educație
  • Găsiți un contabil
  • Găsește un Partener
  • Devino Partener
Despre Noi
  • Compania noastră
  • Active de marcă
  • Contactați-ne
  • Locuri de muncă
  • Evenimente
  • Podcast
  • Blog
  • Clienți
  • Aspecte juridice • Confidențialitate
  • Securitate
الْعَرَبيّة 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 este o suită de aplicații de afaceri open source care acoperă toate nevoile companiei dvs.: CRM, comerț electronic, contabilitate, inventar, punct de vânzare, management de proiect etc.

Propunerea de valoare unică a Odoo este să fie în același timp foarte ușor de utilizat și complet integrat.

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