forked from OCA/server-env
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] server_environment: Migration to 18.0
- Loading branch information
1 parent
b9ec8c3
commit 1105d02
Showing
6 changed files
with
67 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,13 @@ server configuration environment files | |
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github | ||
:target: https://github.com/OCA/server-env/tree/17.0/server_environment | ||
:target: https://github.com/OCA/server-env/tree/18.0/server_environment | ||
:alt: OCA/server-env | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/server-env-17-0/server-env-17-0-server_environment | ||
:target: https://translation.odoo-community.org/projects/server-env-18-0/server-env-18-0-server_environment | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-env&target_branch=17.0 | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-env&target_branch=18.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
@@ -34,9 +34,9 @@ on the configured environment: you define the environment in the main | |
configuration file, and the values for the various possible environments | ||
are stored in the ``server_environment_files`` companion module. | ||
|
||
The ``server_environment_files`` module is optional, the values can be set using | ||
an environment variable with a fallback on default values in the database. you | ||
will be able to overwrite some odoo options. | ||
The ``server_environment_files`` module is optional, the values can be | ||
set using an environment variable with a fallback on default values in | ||
the database. | ||
|
||
The configuration read from the files are visible under the | ||
Configuration menu. If you are not in the 'dev' environment you will not | ||
|
@@ -96,18 +96,12 @@ You can edit the settings you need in the ``server_environment_files`` | |
addon. The ``server_environment_files_sample`` can be used as an | ||
example: | ||
|
||
* values common to all / most environments can be stored in the | ||
``default/`` directory using the .ini file syntax; | ||
* each environment you need to define is stored in its own directory | ||
and can override or extend default values; | ||
* you can override or extend values in the main configuration | ||
file of your instance; | ||
* In some platforms (like odoo.sh where production config file is copied to staging) | ||
it can be usefull to overwrite options write in the `[options]` section. You must | ||
allow the overwrite by adding `server_environment_allow_overwrite_options_section = True`` | ||
to the former `odoo.cfg` config file or through the environment variable: | ||
`export SERVER_ENVIRONMENT_ALLOW_OVERWRITE_OPTIONS_SECTION=True` (if both are set | ||
config file take precedent). | ||
- values common to all / most environments can be stored in the | ||
``default/`` directory using the .ini file syntax; | ||
- each environment you need to define is stored in its own directory | ||
and can override or extend default values; | ||
- you can override or extend values in the main configuration file of | ||
your instance; | ||
|
||
Environment variable | ||
-------------------- | ||
|
@@ -231,7 +225,7 @@ Bug Tracker | |
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-env/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/server-env/issues/new?body=module:%20server_environment%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
`feedback <https://github.com/OCA/server-env/issues/new?body=module:%20server_environment%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
|
@@ -258,6 +252,13 @@ Contributors | |
- Thomas Binfeld <[email protected]> | ||
- Stéphane Bidoul <[email protected]> | ||
- Simone Orsi <[email protected]> | ||
- Thien Vo <[email protected]> | ||
|
||
Other credits | ||
------------- | ||
|
||
The migration of this module from 17.0 to 18.0 was financially supported | ||
by Camptocamp. | ||
|
||
Maintainers | ||
----------- | ||
|
@@ -272,6 +273,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose | |
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/server-env <https://github.com/OCA/server-env/tree/17.0/server_environment>`_ project on GitHub. | ||
This module is part of the `OCA/server-env <https://github.com/OCA/server-env/tree/18.0/server_environment>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,11 @@ | |
# @author Simone Orsi <[email protected]> | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) | ||
|
||
import logging | ||
|
||
from odoo import api, fields, models | ||
|
||
from odoo.addons.http_routing.models.ir_http import slugify | ||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class ServerEnvTechNameMixin(models.AbstractModel): | ||
|
@@ -35,43 +37,24 @@ class ServerEnvTechNameMixin(models.AbstractModel): | |
"`tech_name` must be unique!", | ||
) | ||
] | ||
# TODO: could leverage the new option for computable / writable fields | ||
# and get rid of some onchange / read / write code. | ||
tech_name = fields.Char( | ||
help="Unique name for technical purposes. Eg: server env keys.", | ||
compute="_compute_tech_name", | ||
copy=False, | ||
readonly=False, | ||
store=True, | ||
help="Unique name for technical purposes. Eg: server env keys.", | ||
) | ||
|
||
_server_env_section_name_field = "tech_name" | ||
|
||
@api.onchange("name") | ||
def _onchange_name_for_tech(self): | ||
# Keep this specific name for the method to avoid possible overrides | ||
# of existing `_onchange_name` methods | ||
if self.name and not self.tech_name: | ||
self.tech_name = self.name | ||
|
||
@api.onchange("tech_name") | ||
def _onchange_tech_name(self): | ||
if self.tech_name: | ||
# make sure is normalized | ||
self.tech_name = self._normalize_tech_name(self.tech_name) | ||
|
||
@api.model_create_multi | ||
def create(self, vals_list): | ||
for vals in vals_list: | ||
self._handle_tech_name(vals) | ||
return super().create(vals_list) | ||
|
||
def write(self, vals): | ||
self._handle_tech_name(vals) | ||
return super().write(vals) | ||
|
||
def _handle_tech_name(self, vals): | ||
# make sure technical names are always there | ||
if not vals.get("tech_name") and vals.get("name"): | ||
vals["tech_name"] = self._normalize_tech_name(vals["name"]) | ||
|
||
@staticmethod | ||
def _normalize_tech_name(name): | ||
return slugify(name).replace("-", "_") | ||
@api.depends("name") | ||
def _compute_tech_name(self): | ||
for record in self: | ||
if record.name and not record.tech_name: | ||
record.tech_name = self._normalize_tech_name(record.name) | ||
_logger.warning( | ||
f"Tech name automatically generated from name: {record.tech_name}" | ||
) | ||
|
||
def _normalize_tech_name(self, name): | ||
return self.env["ir.http"]._slugify(name).replace("-", "_") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
- Thomas Binfeld \<<[email protected]>\> | ||
- Stéphane Bidoul \<<[email protected]>\> | ||
- Simone Orsi \<<[email protected]>\> | ||
- Thien Vo \<<[email protected]>\> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The migration of this module from 17.0 to 18.0 was financially supported by Camptocamp. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters