0

I would like to know how to declare global variable and call it in any module. In community used os.getenv(), in enterprise I've switch to this one: A Python request such as:

Set param and value,

self.env['ir.config_parameter'].sudo().set_param('global.variable', global_variable )

Get value:

global_variable = self.env['ir.config_parameter'].sudo().get_param('global.variable')

I think it is not very efficient as I will make many calls to the database, for all global variables that I have. Any tips/suggestions for improvement are welcome...

Dori
  • 175
  • 16
  • `os.getenv()` is a base functions provided by python os module, you can use it in any odoo versions, you just need to add environment variable to you OS – SDBot Mar 24 '22 at 16:18
  • That's the question how to define them in Odoo enterprise? – Dori Mar 25 '22 at 09:33
  • Set enviroment variables to your OS not Odoo, are you using Odoo.sh or self host? – SDBot Mar 25 '22 at 10:07
  • Im using odoo.sh, I do not know where to put them there...and the only work around that found was to put them in the model ir.config_parameter... any idea where I can set them in OS? – Dori Mar 25 '22 at 10:18
  • Why you think it isn't efficient? how many calls are you doing? PS: You don't neet to set parameters by Python code, you achieve that with a simple xml data record with noupdate="1". If you use OS enviroments you have to do the same every time you install/migrate your inplementation. – Juan Salcedo Jun 30 '22 at 06:50

0 Answers0