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

What would be a good way to determine from code whether the code is running on a production or a dev environment in odoo.sh ?

Are there any environment variables injected by odoo.sh that are accessible ?


A use case would be to add the 'debug_mode' variable to the google analytics gtag on all non production environment by default.

아바타
취소

you can check that code in each branch of github repo(specific for that project) and check found branch related stage in odoo.sh it could be production, staging or dev

작성자 베스트 답변

This works:


is_production = fields.Boolean(compute='_compute_is_production', string='Is Production')        
def_compute_is_production(self):       
    prod = os.environ.get("ODOO_STAGE") == "production"       
    for website inself:
        website.is_production = prod


아바타
취소

"production" or "staging" or "dev"

We also have ODOO_VERSION which will match to the current build's Odoo version (eg: 15.0, 16.0, 17.0)

관련 게시물 답글 화면 활동
1
7월 25
1891
4
4월 25
12295
1
1월 25
1484
1
1월 25
5016
1
1월 25
2250