Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
3401 มุมมอง

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)

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 25
1673
4
เม.ย. 25
11992
1
ม.ค. 25
1313
1
ม.ค. 25
4702
1
ม.ค. 25
1990