Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Property Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Client-side variables

Subscribe

Get notified when there's activity on this post

This question has been flagged
clientcontextvariableodoo10
1 Reply
6005 Views
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
Discard
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)
Best Answer

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
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Call a wizard, in context pass an id. Not recognized Solved
wizard context odoo10
Avatar
1
Aug 19
5652
odoo 10 : How to get active ID in JS code? Solved
context js odoo10
Avatar
Avatar
Avatar
3
Apr 18
13339
How to Edit calendar view saved record by passing context or else way?
calendar context odoo odoo10
Avatar
0
Jul 20
6209
How to change language of one2many field in Odoo10
one2many context odoo odoo10
Avatar
Avatar
Avatar
Avatar
5
Jan 20
5765
SHOW/HIDE A COLUMN IN A TREE VIEW on odoo 10
filter treeview context odoo10
Avatar
0
Mar 18
4831
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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