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
    Food & Hospitality
    • 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
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et 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
    Browse all 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
    • Devenez partenaire
    • Services for Partners
    • 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 fields based on curent user login

S'inscrire

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

Cette question a été signalée
12 Réponses
7059 Vues
Avatar
Jérôme

Hello

Sorry for my poor english i'm french ;-)

So.. I would like to hide fields based on curent user login.

I have some 10 employee and 10 users associate.

- i want that all users can see the 10 employee data but exept one (or more) field for exemple the field "phone"

- I want just the users login can modifiy is own employee data

I don't know how to do!!!

i try to put the condition this condition on the field but it doesn't work!

{'invisible': [('user_id','!=','user_id')]}

How can i give the user login and compare it to the related user of the employee?


0
Avatar
Ignorer
Ray Carnes

i tried this but the result is : name 'uid' is not defined I'm on odoo 8, i think this work on openerp 6 but not now!!!!

Axel Mendoza

I have a solution for you, let me write it

Axel Mendoza

see my updated answer

Akhil P Sivan

The users can see all the fields of their own employee data? And they can see only limited fields of other employees, but can't modify. You need to have like this?

Avatar
Pawan
Meilleure réponse

Jermoe,

You can do this by having a record rule for hr.employee object in which you can have domain like:
[('user_id','=',user.id)]

and remember to allow this rule for WRITE permission only(uncheck create/read/delete boxes)

and assign this to employee group.

Hope it helps!    

3
Avatar
Ignorer
Avatar
Axel Mendoza
Meilleure réponse

You need to define a field function that return the uid of the user:

class test_x(osv.osv):
    _name = 'model_x'
    def _get_uid(self, cr, uid, ids, field_name, args, context=None):
        return dict([(idx, uid) for idx in ids])
    _columns = {
        'user_uid': fields.function(_get_uid, type='integer', string='User UID'),
    }
    _defaults = {
        'user_uid': lambda self, cr, uid, c: uid,
    }

Try like this:

<field name="user_uid" invisible="1"/>
<field name="field_x" attrs="{'invisible': [('user_id','!=',user_uid)]}"/>


1
Avatar
Ignorer
Avatar
Jérôme
Auteur Meilleure réponse

hello Axel

thank you, I think it's the good solution.

I try this, i create a new module but i have an error when i update my module list:

    'user_uid': fields.function(_get_uid, type='integer', string='User UID'),

    AttributeError: 'module' object has no attribute 'function'

Can you help me?


this is my hr_employee_cu.py

from openerp.osv import osv, fields

class HrEmployeeCu(osv.osv):

_inherit = 'hr.employee'

def _get_uid(self, cr, uid, ids, field_name, args, context=None):

return dict([(idx, uid) for idx in ids])

_columns = {

'user_uid': fields.function(_get_uid, type='integer', string='User UID'),

}

_defaults = {

'user_uid': lambda self, cr, uid, c: uid,

}


Hello Axel

Sorry but i don’t understand ?

What it fixed?

0
Avatar
Ignorer
Axel Mendoza

It's fixed in your own answer

Jérôme
Auteur

you have modify my code directly in my code? Sorry but i don't see the difference! It's late in france my eye nor really open ;-)

Axel Mendoza

let me put the changes in bold

Jérôme
Auteur

OK now the module installing whitout error but my field 'user_uid' doesn't create in database! from openerp import models, fields class HrEmployeeCu(models.Model): _inherit = 'hr.employee' user_uid = fields.Integer(string='User UID', compute='_get_uid') def _get_uid(self, cr, uid, ids, field_name, args, context=None): return dict([(idx, uid) for idx in ids]) _defaults = { 'user_uid': lambda self, cr, uid, c: uid, }

Avatar
Anass Ahmed
Meilleure réponse

Best way is to use *Groups* for different users, then put on your field the following attribute (for example: Salesman group only sees this field): groups="sale.group_sale_salesman" You can refer to the *Security* documentation section to know how to create new group from *data.xml* and assign users to it.

0
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
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
  • Devenez 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