From 0d5d0c30f5ff24dee3367d105d30f5761f8f0a7e Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 16 Oct 2020 11:32:23 +0200 Subject: [PATCH] [IMP] server_environmnet_ir_config_parameter: display in the config parameter list and form views the new field is_environment, and make the key and values readonly if checked --- .../README.rst | 3 +- .../__manifest__.py | 3 ++ .../i18n/de.po | 13 +++++++ .../i18n/es.po | 13 +++++++ .../i18n/it.po | 13 +++++++ .../i18n/nl_NL.po | 13 +++++++ .../i18n/ro.po | 13 +++++++ ...server_environment_ir_config_parameter.pot | 13 +++++++ .../models/ir_config_parameter.py | 16 +++++++- .../readme/CONTRIBUTORS.rst | 1 + .../static/description/index.html | 1 + .../views/view_ir_config_parameter.xml | 39 +++++++++++++++++++ 12 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 server_environment_ir_config_parameter/views/view_ir_config_parameter.xml diff --git a/server_environment_ir_config_parameter/README.rst b/server_environment_ir_config_parameter/README.rst index fe003ad..6640adc 100644 --- a/server_environment_ir_config_parameter/README.rst +++ b/server_environment_ir_config_parameter/README.rst @@ -23,7 +23,7 @@ Server Environment Ir Config Parameter :target: https://runbot.odoo-community.org/runbot/254/16.0 :alt: Try me on Runbot -|badge1| |badge2| |badge3| |badge4| |badge5| +|badge1| |badge2| |badge3| |badge4| |badge5| Override System Parameters from server environment file. @@ -91,6 +91,7 @@ Contributors * Stéphane Bidoul (https://acsone.eu) * Thierry Ducrest * Gilles Meyomesse (https://acsone.eu) +* Sylvain LE GAL (https://www.twitter.com/legalsylvain) Other credits ~~~~~~~~~~~~~ diff --git a/server_environment_ir_config_parameter/__manifest__.py b/server_environment_ir_config_parameter/__manifest__.py index bc2c7fb..bbdad3b 100644 --- a/server_environment_ir_config_parameter/__manifest__.py +++ b/server_environment_ir_config_parameter/__manifest__.py @@ -10,4 +10,7 @@ "author": "ACSONE SA/NV, Odoo Community Association (OCA)", "website": "https://github.com/OCA/server-env", "depends": ["server_environment"], + "data": [ + "views/view_ir_config_parameter.xml", + ], } diff --git a/server_environment_ir_config_parameter/i18n/de.po b/server_environment_ir_config_parameter/i18n/de.po index 62e4979..c9de0a8 100644 --- a/server_environment_ir_config_parameter/i18n/de.po +++ b/server_environment_ir_config_parameter/i18n/de.po @@ -19,6 +19,19 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: server_environment_ir_config_parameter +#: model:ir.model.fields,field_description:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "Defined by environment" +msgstr "" + +#. module: server_environment_ir_config_parameter +#: model:ir.model.fields,help:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "" +"If check, the value in the database will be ignored and alternatively, the " +"system will use the key defined in your odoo.cfg environment file." +msgstr "" + +#. module: server_environment_ir_config_parameter +#. odoo-python #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" diff --git a/server_environment_ir_config_parameter/i18n/es.po b/server_environment_ir_config_parameter/i18n/es.po index c7ea92e..8c4d8ea 100644 --- a/server_environment_ir_config_parameter/i18n/es.po +++ b/server_environment_ir_config_parameter/i18n/es.po @@ -19,6 +19,19 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: server_environment_ir_config_parameter +#: model:ir.model.fields,field_description:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "Defined by environment" +msgstr "" + +#. module: server_environment_ir_config_parameter +#: model:ir.model.fields,help:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "" +"If check, the value in the database will be ignored and alternatively, the " +"system will use the key defined in your odoo.cfg environment file." +msgstr "" + +#. module: server_environment_ir_config_parameter +#. odoo-python #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" diff --git a/server_environment_ir_config_parameter/i18n/it.po b/server_environment_ir_config_parameter/i18n/it.po index 4c61c5e..da0c37b 100644 --- a/server_environment_ir_config_parameter/i18n/it.po +++ b/server_environment_ir_config_parameter/i18n/it.po @@ -19,6 +19,19 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: server_environment_ir_config_parameter +#: model:ir.model.fields,field_description:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "Defined by environment" +msgstr "" + +#. module: server_environment_ir_config_parameter +#: model:ir.model.fields,help:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "" +"If check, the value in the database will be ignored and alternatively, the " +"system will use the key defined in your odoo.cfg environment file." +msgstr "" + +#. module: server_environment_ir_config_parameter +#. odoo-python #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" diff --git a/server_environment_ir_config_parameter/i18n/nl_NL.po b/server_environment_ir_config_parameter/i18n/nl_NL.po index 9ad1b47..900b4a0 100644 --- a/server_environment_ir_config_parameter/i18n/nl_NL.po +++ b/server_environment_ir_config_parameter/i18n/nl_NL.po @@ -20,6 +20,19 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: server_environment_ir_config_parameter +#: model:ir.model.fields,field_description:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "Defined by environment" +msgstr "" + +#. module: server_environment_ir_config_parameter +#: model:ir.model.fields,help:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "" +"If check, the value in the database will be ignored and alternatively, the " +"system will use the key defined in your odoo.cfg environment file." +msgstr "" + +#. module: server_environment_ir_config_parameter +#. odoo-python #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" diff --git a/server_environment_ir_config_parameter/i18n/ro.po b/server_environment_ir_config_parameter/i18n/ro.po index 84161e6..cd11348 100644 --- a/server_environment_ir_config_parameter/i18n/ro.po +++ b/server_environment_ir_config_parameter/i18n/ro.po @@ -20,6 +20,19 @@ msgstr "" "2:1));\n" #. module: server_environment_ir_config_parameter +#: model:ir.model.fields,field_description:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "Defined by environment" +msgstr "" + +#. module: server_environment_ir_config_parameter +#: model:ir.model.fields,help:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "" +"If check, the value in the database will be ignored and alternatively, the " +"system will use the key defined in your odoo.cfg environment file." +msgstr "" + +#. module: server_environment_ir_config_parameter +#. odoo-python #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" diff --git a/server_environment_ir_config_parameter/i18n/server_environment_ir_config_parameter.pot b/server_environment_ir_config_parameter/i18n/server_environment_ir_config_parameter.pot index 6ae3161..231ddf9 100644 --- a/server_environment_ir_config_parameter/i18n/server_environment_ir_config_parameter.pot +++ b/server_environment_ir_config_parameter/i18n/server_environment_ir_config_parameter.pot @@ -14,6 +14,19 @@ msgstr "" "Plural-Forms: \n" #. module: server_environment_ir_config_parameter +#: model:ir.model.fields,field_description:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "Defined by environment" +msgstr "" + +#. module: server_environment_ir_config_parameter +#: model:ir.model.fields,help:server_environment_ir_config_parameter.field_ir_config_parameter__is_environment +msgid "" +"If check, the value in the database will be ignored and alternatively, the " +"system will use the key defined in your odoo.cfg environment file." +msgstr "" + +#. module: server_environment_ir_config_parameter +#. odoo-python #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" diff --git a/server_environment_ir_config_parameter/models/ir_config_parameter.py b/server_environment_ir_config_parameter/models/ir_config_parameter.py index fa9c1c1..3c7aa9c 100644 --- a/server_environment_ir_config_parameter/models/ir_config_parameter.py +++ b/server_environment_ir_config_parameter/models/ir_config_parameter.py @@ -1,10 +1,10 @@ # Copyright 2016-2018 ACSONE SA/NV # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import _, api, models +from odoo import _, api, fields, models from odoo.exceptions import UserError -from odoo.addons.server_environment import serv_config +from odoo.addons.server_environment.server_env import serv_config SECTION = "ir.config_parameter" @@ -13,6 +13,18 @@ class IrConfigParameter(models.Model): _inherit = "ir.config_parameter" + is_environment = fields.Boolean( + string="Defined by environment", + compute="_compute_is_environment", + help="If check, the value in the database will be ignored" + " and alternatively, the system will use the key defined" + " in your odoo.cfg environment file.", + ) + + def _compute_is_environment(self): + for parameter in self: + parameter.is_environment = serv_config.has_option(SECTION, parameter.key) + @api.model def get_param(self, key, default=False): value = super().get_param(key, default=None) diff --git a/server_environment_ir_config_parameter/readme/CONTRIBUTORS.rst b/server_environment_ir_config_parameter/readme/CONTRIBUTORS.rst index c3ae88d..96047e9 100644 --- a/server_environment_ir_config_parameter/readme/CONTRIBUTORS.rst +++ b/server_environment_ir_config_parameter/readme/CONTRIBUTORS.rst @@ -1,3 +1,4 @@ * Stéphane Bidoul (https://acsone.eu) * Thierry Ducrest * Gilles Meyomesse (https://acsone.eu) +* Sylvain LE GAL (https://www.twitter.com/legalsylvain) diff --git a/server_environment_ir_config_parameter/static/description/index.html b/server_environment_ir_config_parameter/static/description/index.html index 44d3153..95cf11b 100644 --- a/server_environment_ir_config_parameter/static/description/index.html +++ b/server_environment_ir_config_parameter/static/description/index.html @@ -435,6 +435,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
  • Stéphane Bidoul <stephane.bidoul@acsone.eu> (https://acsone.eu)
  • Thierry Ducrest <thierry.ducrest@camptocamp.com>
  • Gilles Meyomesse <gilles.meyomesse@acsone.eu> (https://acsone.eu)
  • +
  • Sylvain LE GAL (https://www.twitter.com/legalsylvain)
  • diff --git a/server_environment_ir_config_parameter/views/view_ir_config_parameter.xml b/server_environment_ir_config_parameter/views/view_ir_config_parameter.xml new file mode 100644 index 0000000..fdc6f96 --- /dev/null +++ b/server_environment_ir_config_parameter/views/view_ir_config_parameter.xml @@ -0,0 +1,39 @@ + + + + + + ir.config_parameter + + + + + + + + + + ir.config_parameter + + + + + + + {'readonly': [('is_environment', '=', True)]} + + + {'readonly': [('is_environment', '=', True)]} + + + + +