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

what is the differnce between self.env.uid and self.env.user ?

S'inscrire

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

Cette question a été signalée
developmentcommunitylearnModule
14 Réponses
34839 Vues
Avatar
Usman Farzand

thanks in Advance please define it in detail...

1
Avatar
Ignorer
Sehrish

get logged in user id: http://learnopenerp.blogspot.com/2018/08/get-current-logged-in-user-id-in-odoo.html

Avatar
Niyas Raphy (Walnut Software Solutions)
Meilleure réponse

Hi,

self.env.uid will give the id of the current user

and

self.env.user will return the current user record

Example

self.env.uid - 1
self.env.user - res.users(1,)

Thanks

15
Avatar
Ignorer
Avatar
Palkesh Baraiya
Meilleure réponse

hi, Usman Farzand


self.env.uid will return Id of Current Login User

self.env.user will return Current User Record





2
Avatar
Ignorer
Niyas Raphy (Walnut Software Solutions)

Hey,

Earlier when i have checked my answer it was accepted and have green tick in it, and now it seems the green tick for you answer.

Anything new you have added in the answer ? or my answer is wrong ? was not my clear ?

Niyas Raphy (Walnut Software Solutions)

* was not my answer clear ?

Palkesh Baraiya

no you are right, but you not mentation that Current Login User. i think

Niyas Raphy (Walnut Software Solutions)

What does the meaning of current user ? Didn't see that ? Are you saying current user and current login user is different ?

Look even in your answer you have used current user record.

Usman Farzand
Auteur

you both are right can you please any one tell me if it's different from each other

self.env.uid - 1

self.env.user - res.users(1,)

then why condition is same for both ????

@api.multi

def do_clear_done(self):

domain = [('is_done', '=', True),'|',('user_id', '=', self.env.uid),

('user_id', '=', False)]

dones = self.search(domain)

dones.write({'active': False})

return True

@api.multi

def do_toggle_done(self):

for task in self:

if task.user_id != self.env.user:

raise ValidationError('Only the Responsible can do this!')

return super(TodoTask, self).do_toggle_done()

if condition chk and domain chk in same way can any one tell me more in detail sorry i'm beginner

Usman Farzand
Auteur

('user_id', '=', self.env.uid),

if task.user_id != self.env.user:

noted point why ?

Palkesh Baraiya

see the thing is, when You simply write 'user_id' than it will return one Object like res.users(1,)

and if you want to put condition on it than u required Object in other side also otherwise it give Error to you. so we use self.env.user.

And For the Domain case i think while You Search any Record or Applying Domain on Record then you need ID of the Record, so domain = [('is_done', '=', True),'|',('user_id', '=', self.env.uid),

Usman Farzand
Auteur

@ Palkesh Baraiya if i write

if task.user_id != self.env.id:

excpt this

if task.user_id != self.env.user

is it will correct ?

thanks for answer i clear my more concept....

Palkesh Baraiya

Look If you want to Compare only ID than u can write

if task.user_id.id != self.env.uid:

it will compare your 'user_id' with current Login User ID. like

if 'user_id' = 1 and Current Login user('self.env.uid') = 1

than Condition was fulfil.

and other case was,

if task.user_id != self.env.user

it will use 'user_id' as object like 'res.partner(1,)' and for self.env.user as 'Current Login User Object like res.users(1,)'

Usman Farzand
Auteur

excellent thank you soo much @Palkesh Baraiya....thanks again...

Avatar
subbarao
Meilleure réponse

self.env.uid will return Database table Id  (ex: admin login --> 1)

self.env.user will return ORM browse object (ex: admin login --> res.user(1))

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
Publications associées Réponses Vues Activité
multi tenancy odoo 12 or 13
development community
Avatar
0
mai 20
3867
How active is the Odoo community?
development community
Avatar
Avatar
1
mars 15
7728
Load custom module after al other modules
development customization Module
Avatar
0
août 16
3483
how to set up odoo community on docker Résolu
development community docker v17
Avatar
Avatar
Avatar
Avatar
3
avr. 25
21163
What are the differences between Community and Enterprise when it comes to module development?
development community enterprise odoo11
Avatar
Avatar
1
oct. 19
4055
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