콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
22651 화면

Hi, i'm using odoo v11.

I was wondering if it's possible (and, if so, which is the most standard way) to define global variables that may be accessible everywhere in the python side of my odoo deployement.

My company is planning to release several odoo deployements for different customers, but most of the functionalities would still be the same across the different deployements. 

I'd like to code my custom modules in the most general way possible, delegating the customer-specific features to server-side conditions like

if(is_feature_xyz_active):
    #do some nifty stuff

where 'is_feature_xyz_active' is a global variable saved somewhere, whose value will be set according to the requests of the specific customer.

Where should I save those variables, and how should I access them?

Thank you very much in advance.

아바타
취소
베스트 답변

Check out the ir.config_parameter model.

A Python request such as:

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

will return the value stored and something like:

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

will set it.


아바타
취소
작성자

Thank you very much for your answer! Cheers.

관련 게시물 답글 화면 활동
2
7월 24
2504
1
6월 24
4995
1
10월 23
10680
1
10월 23
98
1
8월 23
2193