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í
    Food & Hospitality
    • Bar a Pub
    • Restaurace
    • Fast Food
    • Guest House
    • Distributor nápojů
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architektonická firma
    • Stavba
    • Správa nemovitostí
    • Zahradnictví
    • Asociace vlastníků nemovitosti
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketingová agentura
    • Právník
    • Akvizice talentů
    • Audit a certifikace
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Korporátní dárky
    Zdraví a fitness
    • Sportovní klub
    • Prodejna brýli
    • Fitness Centrum
    • Wellness praktikové
    • Lékárna
    • Kadeřnictví
    Trades
    • Údržbář
    • IT hardware a podpora
    • Solar Energy Systems
    • Výrobce obuvi
    • Úklidové služby
    • HVAC Services
    Others
    • Nonprofit Organization
    • 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 field readonly for user

Odebírat

Get notified when there's activity on this post

This question has been flagged
readonly
8 Odpovědi
8447 Zobrazení
Avatar
Jagdish Panchal

HI,

I have 3 field in my view

                                <field name="name" />
                                <field name="date" />
                                <field name="nbc" />

I want set name and date field read only for hr_manager. how can i ?

Any help ??

 

 

1
Avatar
Zrušit
Avatar
Prakash
Nejlepší odpověď

Create function field that returns a value based on the user's group and then use attrs attributes on fields to control.

Reference :https://answers.launchpad.net/openobject-server/+question/178779

2
Avatar
Zrušit
Jagdish Panchal
Autor

Thanks

Avatar
Dhinesh
Nejlepší odpověď

Hi, you can use this as example...

'name': fields.char('Name', size=128, read=['base.group_userA'], write=['base.group_userB'] )

Read will allow the user group to view and Write will allow the user group to edit the field..

1
Avatar
Zrušit
Jagdish Panchal
Autor

I have try this but its not working

Avatar
René Schuster
Nejlepší odpověď

*EDITED*

One solution is to combine a function field with the attrs tag:

.py:

def _get_uid_is_manager(self, cr, uid, ids, field_name, arg, context=None):
        res = {};
        manager_group_id = self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'group_hr_manager').id
        manager_ids = self.pool.get('res.user').search('groups_id', '=', manager_group_id);
        for obj in self.browse(cr, uid, ids, context=context):
            res[obj.id] = uid in manager_ids;
        return res;

'uid_is_manager': fields_function(_get_uid_is_manager, type='boolean', method=True, string='Current User is Manager?'

.xml:

<field name="name" attrs="{'readonly': [('uid_is_manager' ,'=', True)]}"/>
<field name="date" attrs="{'readonly': [('uid_is_manager' ,'=', True)]}"/>

 

Regards.

1
Avatar
Zrušit
Jagdish Panchal
Autor

@René Schuster: Thanks for the answer, I want make read only dont want hide.By using this code its hide for other user.

René Schuster

Sorry, got you wrong. I've edited my answer (but was slower than prakash ^^).

Avatar
Maduka Sopulu
Nejlepší odpověď

Use fields_get to achieve this:

Eg. 

@api.model
def fields_view_get(self, view_id='OdooModule.test_form_view', view_type='form', toolbar=False, submenu=False):
res = super(Test, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar,
submenu = submenu)
doc = etree.XML(res['arch'])
if not self.env.user.has_group('group_admin') or self.env.user.has_group('group_ad_doctor'):
for node in doc.xpath("//field[@name='laboratory']"):
node.set('modifiers', '{"readonly": true}')
for node in doc.xpath("//field[@name='test_type_id']"):
node.set('modifiers', '{"readonly": true}')

for node in doc.xpath("//field[@name='patient_id']"):
node.set('modifiers', '{"readonly": true}')


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

0
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
Odoo Sales
readonly
Avatar
Avatar
1
říj 24
7815
Make field readonly based on group Vyřešeno
readonly
Avatar
Avatar
Avatar
Avatar
9
čvc 21
63956
How to make specific field read-only after saving the record Vyřešeno
xml readonly
Avatar
Avatar
Avatar
3
srp 24
16769
Form view is visible but its data cannot modified
readonly lead
Avatar
0
kvě 23
2246
How can we make field read only based on group and status?
readonly group
Avatar
Avatar
1
bře 23
2933
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