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
    • Intelligence artificielle
    • 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
    • Supermarché
    • 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
    • Homme à tout faire
    • 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
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

Client-side variables

S'inscrire

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

Cette question a été signalée
clientcontextvariableodoo10
1 Répondre
6056 Vues
Avatar
Antoine Baron

Hi everyone, 

I'm currently trying to implement a client-side variable on Odoo 10 (if that makes any sense).

What I mean by that would be a variable usable globally in Odoo, easily readable/editable, and bound to only one computer.

I tried several methods:

  1.  In my ignorance, I tried to use a python file globalv.py inside which I put the line "variable=0". Then I imported it anytime I needed the variable in my code. This way I had almost everything I needed, except that the variable was shared by every computer of the network. It made me understand that the python methods were only used server side (at least to my knowledge).

  2. I then tried to use Javascript which is said to be client-side. As a complete beginner, I defined a variable in an odoo function but couldn't export it in order to use it or manipulate it like something passed by reference in C++ (I think I can't use pointers here). Therefore, I gave up on Javascript as well. 

  3. Then I tried to use the context, because I believe it to be client-side (not sure tho?). The problem is, it seems the context is in fact bound to a recordset, and it looks complicated to pass my variable everytime and everywhere since I in fact need it everytime and everywhere.

Finally I imagined that the user accessible with self.env.user, is client-side as two computers can connect to two different users even though they're connected to the same server. I tried to modify the api completely to include a variable inside the environment class and a custom sudo that would edit this variable but I gave up since little by little, I was modifying every method and class.

I hope you can tell me if I'm being logical here or if it's completely impossible to implement such a thing. (And if someone can explicit what is the context or see some inaccurate detail here, please feel free to share your knowledge too)



1
Avatar
Ignorer
Sudhir Arya (ERP Harbor Consulting Services)

I really appreciate for your efforts to add all the possible details in the question. Such details really help people to give answer. +1 for good question and enough details.

Avatar
Sudhir Arya (ERP Harbor Consulting Services)
Meilleure réponse

Hi Antoine,

Why don't you use Odoo HTTP session? This will be saved at client-side for temporary time period.

from odoo.http import request

# Save value in session by using current logged user ID as key
request.session[request.env.uid] = 'Your Value'

#Get session value
print request.session[request.env.uid]

I hope this will help you at some level to move further.

Sudhir Arya
ERP Harbor Consulting Services
Skype:sudhir@erpharbor.com
Website: http://www.erpharbor.com
5
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é
Call a wizard, in context pass an id. Not recognized Résolu
wizard context odoo10
Avatar
1
août 19
5729
odoo 10 : How to get active ID in JS code? Résolu
context js odoo10
Avatar
Avatar
Avatar
3
avr. 18
13390
How to Edit calendar view saved record by passing context or else way?
calendar context odoo odoo10
Avatar
0
juil. 20
6259
How to change language of one2many field in Odoo10
one2many context odoo odoo10
Avatar
Avatar
Avatar
Avatar
5
janv. 20
5826
SHOW/HIDE A COLUMN IN A TREE VIEW on odoo 10
filter treeview context odoo10
Avatar
0
mars 18
4906
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 Svenska ภาษาไทย 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