Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Is it possible to make a field readonly for users under particular group in openerp 7?

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
securityv7readonlyaclgroups
23 Besvarelser
49399 Visninger
Avatar
Omal Bastin

Hi, I have a field in invoice(say reference number). Only the users coming under the group 'Financial Manager' can edit the field. All other users can view these fields as readonly field. Is it possible to achieve this?

Thanks in advance.

4
Avatar
Kassér
Ray Carnes

@Omal Bastin  Thanks for your answer . It really helped me in my project.

Sehrish

Idea:

Create a boolean field, make that field True for those group of users, for which you want to make field readonly. And on the basis of that boolean field, make desired field readonly.

Avatar
Omal Bastin
Forfatter Bedste svar

Another simple solution.

First create your form view. Then inherit the view also specify the groups. for example in sale order form view, i want to make the customer reference(client_order_ref) field is readonly for everyone except group group_financial.

<record id="view_order_form_cust_ref_readonly" model="ir.ui.view">
    <field name="name">sale.order.form.readonly.cust</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="groups_id" eval="[(6, 0, [ref('base.group_financial') ])]"/>
    <field name="arch" type="xml">
        <field name='client_order_ref' position="attributes">
            <attribute name="readonly">0</attribute>
        </field>
    </field>
</record>
11
Avatar
Kassér
Mohammad Alhashash

This is a view customization which can be easily bypassed. It should be used only for useability, not access control and security.

Mohammad Alhashash

Using direct json call for example.

Omal Bastin
Forfatter

Okey then how can we make a field readonly based on group and status/state?

Mohammad Alhashash

Try reading my answer to this question.

Omal Bastin
Forfatter

function field will only execute when saving the record. i dont think create/write is a good option and also the property field.

Alcaline

what if the whole view needs to readonly? Is that possible??

Avatar
Mohammad Alhashash
Bedste svar

If you need to enforce access control to the field, you should not use view customization as it is just a cosmetic behavior and can be easily bypassed.

For a real field/column access control, you should use one of the following options:

Option 1: Use the new field level access control

Using groups='group1, group2, ...' in field definition restricts the field to the specified groups. Currently, you cannot control specific read or write, only allow or prevent access.

In this case, you may create functional field that can be displayed for restricted users. The function for that fields must use the user id openerp.SUPERUSER_ID or integer 1 to read the original field, not the current user id.

from openerp import SUPERUSER_ID
....
class MyClass(osv.Model):
...
    def _myfield_reader(self, cr, uid, ids, name, args, context=None):
        values = self.read(cr, uid, SUPERUSER_ID, ids, ['myfield'], context=context)
        return {v['id']:v['myfield'] for v in values}

Option 2: Override create() and write() methods

By overriding these methods, you can raise AccessError exception if a restricted user tried to write that field value.


Option 3: Use fields.property field

Property fields are stored as ir.property records. So, standard record access control can be used to protect it. Check for example property_account_* fields defined for res.partner in account/partner.py in the account module.

5
Avatar
Kassér
Omal Bastin
Forfatter

i want to make the invoice sequence fields in account.config.settings view in openerp 7(in Settings/Configuration/Accounting) to be readonly for every users except admin(uid=1)

Mohammad Alhashash

You should use a record rule directly on the sequence object. The configuration wizard just takes the user input and applies the change to the sequence object. It is a different concept; check this answer. You can ask another question and someone may help.

Omal Bastin
Forfatter

i didnt get a correct answer but i hope these are some options that we can do. so accepting it as answer

Vaibhav

Suppose I have many2one field "demo_field" and I have two groups "demogroup1","demogroup2" then for demo1 group I want demo_field as default functoinality of many2one field and for demogroup2 demo_field is readonly then what can I do?

Omal Bastin
Forfatter

@vaibhav please check the answer that is marked as correct answer

dirtyHandsPHP

Thanks @Mohammad: Nice and meaning-full answer :)

Macrobeef

hi there! is this possible to achieve in Odoo online ?

Muhammad Awais

The Best Answer

Avatar
Yannick Payot
Bedste svar

If you need it widely, what you can do is override the fields_view_get method.

If this is only for few fields, you can create a readonly related field and use groups in xml to define which one is seen.

<field name="my_field" groups="group_editors"/>
<field name="rel_my_field" groups="group_viewers"/>
0
Avatar
Kassér
Mohammad Alhashash

View customization using fields_view_get or groups=... XML attributes is just for usability, not a security measure. Fields can still be updated easily using simple json queries in browser console.

Yannick Payot

Thanks Mohammad, As question was not tagged with security tag previously, I understood it only as a matter of readonly in visualization. It depends if this is a real security issue or simply a way to ease user's experience.

Vaibhav

Suppose I have many2one field "demo_field" and I have two groups "demogroup1","demogroup2" then for demo1 group I want demo_field as default functionality of many2one field and for demogroup2 demo_field is readonly then what can I do?

Omal Bastin
Forfatter

@vaibhav please check the answer that is marked as correct answer

Vaibhav

but related field is not storing in DB ? So how to display that field in tree view ?

Avatar
Borni DHIFI
Bedste svar

Basic field properties (Required,Readonly,Searchable) can not be modified by the configuration! must change the code in Python and preferably by adding a new module. but you can edit fields personalized.

0
Avatar
Kassér
Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
Permission for a group to edit a single field only? Løst
security v7 groups
Avatar
Avatar
Avatar
Avatar
Avatar
10
dec. 23
37708
How to make many2one field readonly for user which is under specific group?
security attrs readonly groups
Avatar
Avatar
Avatar
Avatar
3
dec. 21
16675
How to add a group to project module properly?
security project v7 groups
Avatar
1
maj 19
9054
How to enable a security group for all users? Løst
security v7 group groups
Avatar
Avatar
Avatar
Avatar
3
nov. 18
22830
Making a user read only, application wise Løst
security readonly groups accessrights Odoo13.0
Avatar
Avatar
Avatar
2
mar. 22
5917
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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