Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Restauration & Hôtellerie
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brasserie
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Commerce
    • Bricoleur
    • Matériel informatique & support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Parcourir toutes les industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenir partenaire
    • Services pour partenaires
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Hide a field based on user groups?

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
securitygroupsopenerp7
4 Réponses
19603 Vues
Avatar
Matias Garcia Isaia

I have a module that adds a flag to res.partner. If the flag for an object is enabled, that object only has to be visible to users in a Priviliged group. In addition, as only those users can set which objects have this flag enabled, they are the only ones who should see the flag field in the views.

I'm using OpenERP 7 and read here (://doc openerp com /trunk/server/04_security/) the use of groups properties, both at object-level and view-level.

But when I open the view with a non-Priviliged user, I get an Access Denied by ACLs for operation: read, uid: 5, model: res.partner, fields: priviliged error.

How can I manage to do this? Am I doing something wrong?

partner_modif.py:

class partner_modif(osv.osv):
    _name = "res.partner"
    _inherit = "res.partner"
    _columns = { 
                  'priviliged': fields.boolean('Priviliged', required=False, groups="my-module.priviliged_users")
                  }
    _defaults = {
                  'priviliged': lambda *a: 0
                 }
partner_modif()

partner_view_modif.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="view_partner_address_form1_inherit" model="ir.ui.view">
            <field name="name">res.partner.address.form1.inherit</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form" />
            <field name="arch" type="xml">
                    <field name="function" position="after">
                        <field name="priviliged" groups="my-module.priviliged_users"/>
                    </field>
              </field>
        </record>

    <record id="my-module.priviliged_users" model="res.groups">
        <field name="name">Priviliged</field>
        <field name="comment">Priviliged users</field>
    </record>

    <record model="ir.rule" id="partner_priviliged_users">
        <field name="name">Priviliged users see all partners</field>
        <field name="model_id" ref="model_res_partner"/>
        <field name="domain_force">[(True, '=', True)]</field>
        <field name="groups" eval="[(4, ref('my-module.priviliged_users'))]"/>
    </record>

    <record model="ir.rule" id="partner_unpriviliged_users">
        <field name="name">Non priviliged users see un-priviliged partners</field>
        <field name="model_id" ref="model_res_partner"/>
        <field name="domain_force">[('priviliged', '=', False)]</field>
        <field name="groups" eval="[(4, ref('base.group_user'))]"/>
    </record>
    </data>
</openerp>
0
Avatar
Ignorer
Xsias

Have you create a ir_model_access.csv in the folder security of your module ?

Matias Garcia Isaia
Auteur

@Xsias: no, I haven't. Never read about. I'm searching now, if you have any recommended link, it'll be appreciated :)

Sehrish

1- How to check login user group in odoo: https://goo.gl/Ts3qqK

2- How to visible and invisible fields in odoo: https://goo.gl/BCxCpk

Avatar
Xsias
Meilleure réponse

Here some links about ir_model_access :

https://accounts.openerp.com/forum/Help-1/question/12430

In this link you can read :

For :

id  name    model_id/id group_id/id perm_read   perm_write  
perm_create perm_unlink
model_bpl_worker_manager    bpl_worker  model_bpl_worker    
group_checkroll_manager 1   1   1   1
  • id = unique identify for the permission (Example: MY_MODULE_res_partner_manager)
  • name = unique name for the permission (Example: res_partner manager)
  • model_id/id = the model unique name of the class you want apply permission on (Example model_res_partner)
  • group_id/id = group permission apply on (yopu can define it in xml group file or call an existing group with syntax module.group_id)
  • perm_read,perm_write,perm_create,perm_unlink = the 4 values for the relative permission to read, write,create,unlink record on defined class. 1 is True (you can do this action) and 0 is Faslse (you can't)

A simple way to understand this file is to read an existing csv in some OpenERP base module like sale, account, product, etc...

Some useful link: http://www.zbeanztech.com/blog/security-openerp

I can give you others links likes :

http://forum.openerp.com/forum/topic16596.html

http://stackoverflow.com/questions/15966676/openerp-7-access-rights-for-user-roles

-2
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Security Fear: Make fields of a model secret without using groups attribute
security groups
Avatar
0
nov. 15
5854
access rights manual Résolu
security groups
Avatar
Avatar
1
mars 15
5837
How to display a view with one field removed for certain groups?
security groups
Avatar
Avatar
1
mars 15
9418
Permission for a group to edit a single field only? Résolu
security v7 groups
Avatar
Avatar
Avatar
Avatar
Avatar
10
déc. 23
38081
Make Field Read Only for specific Group Résolu
security fields groups
Avatar
Avatar
1
oct. 25
11120
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenir partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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