Skip to content

[IMP] web_environment_ribbon: prepare running_env for ribbon name vals #3143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 18.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion web_environment_ribbon/models/web_environment_ribbon_backend.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Copyright 2017 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import os

from odoo import api, models
from odoo.tools.config import config


class WebEnvironmentRibbonBackend(models.AbstractModel):
Expand All @@ -10,7 +13,16 @@ class WebEnvironmentRibbonBackend(models.AbstractModel):

@api.model
def _prepare_ribbon_format_vals(self):
return {"db_name": self.env.cr.dbname}
running_env = (
config.get("running_env")
or os.environ.get("RUNNING_ENV")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly because I'm curious is this list of environment variables supporting a specific odoo docker image or some kind of setup? Could we add DOODBA_ENVIRONMENT to this list?

And it seems that odoo does not support config.get("running_env") are you using a special Odoo Version to support this or am i missunderstanding the code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

running_env is not a standard odoo config, it was added from the oca module server_environment. You can find the usage from this reference

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have also downloaded this module to configure the ribbon display like following

[ir.config_parameter]
ribbon.name={db_name}-staging

But I have to manually change the ribbon for every environment by myself
What I want to do is using single ribbon config for all environment(test/develop/staging/preproduction), like following

[ir.config_parameter]
ribbon.name={db_name}-{running_env}

or os.environ.get("ODOO_STAGE")
or "test"
)
return {
"db_name": self.env.cr.dbname,
"running_env": running_env,
}

@api.model
def _prepare_ribbon_name(self):
Expand Down