Přejít na obsah
Odoo Menu
  • Přihlásit se
  • Vyzkoušejte zdarma
  • Aplikace
    Finance
    • Účetnictví
    • Fakturace
    • Výdaje
    • Spreadsheet (BI)
    • Dokumenty
    • Podpisy
    Prodej
    • CRM
    • Prodej
    • POS Obchod
    • POS Restaurace
    • Předplatné
    • Pronájem
    Webové stránky
    • Webové stránky
    • E-shop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Dodavatelský řetězec
    • Sklad
    • Výroba
    • PLM
    • Nákup
    • Údržba
    • Kvalita
    Lidské zdroje
    • Zaměstnanci
    • Nábor
    • Volno
    • Hodnocení zaměstnanců
    • Doporučení
    • Vozový park
    Marketing
    • Marketing sociálních sítí
    • Emailový marketing
    • SMS Marketing
    • Události
    • Marketingová automatizace
    • Dotazníky
    Služby
    • Projekt
    • Časové výkazy
    • Práce v terénu
    • Helpdesk
    • Plánování
    • Schůzky
    Produktivita
    • Diskuze
    • Schvalování
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Aplikace třetích stran Odoo Studio Odoo cloudová platforma
  • Branže
    Maloobchod
    • Knihkupectví
    • Obchod s oblečením
    • Obchod s nábytkem
    • Potraviny
    • Obchod s hardwarem
    • Hračkářství
    Jídlo a pohostinství
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Penzion
    • Distributor nápojů
    • Hotel
    Nemovitost
    • Realitní kancelář
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Poradenství
    • Účetní firma
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Kov
    • Nábytek
    • Jídlo
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Transakce
    • Údržbář
    • IT hardware a podpora
    • Systémy solární energie
    • Výrobce obuvi
    • Úklidové služby
    • Služby HVAC
    Ostatní
    • Nezisková organizace
    • Agentura pro životní prostředí
    • Pronájem billboardů
    • Fotografování
    • Leasing jízdních kol
    • Prodejce softwaru
    Browse all Industries
  • Komunita
    Edukační program
    • Tutoriály
    • Dokumentace
    • Certifikace
    • Vzdělávání
    • Blog
    • Podcast
    Podpora vzdělávání
    • Vzdělávací program
    • Scale Up! Hra na firmu
    • Navštivte Odoo
    Získat software
    • Stáhnout
    • Porovnejte edice
    • Verze
    Spolupráce
    • Github
    • Fórum
    • Události
    • Překlady
    • Stát se partnerem
    • Services for Partners
    • Registrujte svou účetní firmu
    Získat služby
    • Najít partnera
    • Najít účetní
    • Setkejte se s poradcem
    • Implementační služby
    • Zákaznické reference
    • Podpora
    • Upgrady
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dohodnout demo
  • Ceník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účetnictví
  • Sklad
  • PoS
  • Projekty
  • MRP
All apps
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
You need to be registered to interact with the community.
All Posts Lidé Odznaky
Štítky (View all)
odoo accounting v14 pos v15
O tomto fóru
Pomoc

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

Odebírat

Get notified when there's activity on this post

This question has been flagged
fieldreadonlygroupsattributesodoo9
3 Odpovědi
13228 Zobrazení
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
Zrušit
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.
Autor Nejlepší odpověď

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
Zrušit
Avatar
Divyang Jariwala
Nejlepší odpověď

Hello MouTio,

You can do with py file by fields_view_get method.

1
Avatar
Zrušit
Avatar
Ray Carnes
Nejlepší odpověď

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
Zrušit
Enjoying the discussion? Don't just read, join in!

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

Přihlásit se
Related Posts Odpovědi Zobrazení Aktivita
How to make a field readonly and not editable after save. Vyřešeno
fields readonly attributes odoo9
Avatar
Avatar
Avatar
2
kvě 21
19854
Add Unique Field Like Id
field model odoo9
Avatar
Avatar
Avatar
3
říj 16
7654
make fields as read only based on groups
fields readonly groups
Avatar
Avatar
2
zář 15
5089
How to use the button attribute "args" Vyřešeno
views button attributes odoo9
Avatar
Avatar
1
úno 25
13533
Make field readonly after save it and only user creator and administrator can edit it.
field readonly buttons OdooStudio
Avatar
Avatar
Avatar
Avatar
4
čvn 24
4123
Komunita
  • Tutoriály
  • Dokumentace
  • Fórum
Open Source
  • Stáhnout
  • Github
  • Runbot
  • Překlady
Služby
  • Odoo.sh hostování
  • Podpora
  • Upgrade
  • Nestandardní vývoj
  • Edukační program
  • Najít účetní
  • Najít partnera
  • Stát se partnerem
O nás
  • Naše společnost
  • Podklady značky
  • Kontakujte nás
  • Práce
  • Události
  • Podcast
  • Blog
  • Zákazníci
  • Právní dokumenty • Soukromí
  • Zabezpečení
الْعَرَبيّة 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 je balíček open-source aplikací, které pokrývají všechny potřeby vaší společnosti: CRM, e-shop, účetnictví, sklady, kasy, projektové řízení a další.

Unikátní nabídka od Odoo poskytuje velmi jednoduché uživatelské rozhraní a vše je integrované na jednom místě.

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