diff --git a/server_environment_ir_config_parameter/README.rst b/server_environment_ir_config_parameter/README.rst index 2e7f0ff..dfaa67e 100644 --- a/server_environment_ir_config_parameter/README.rst +++ b/server_environment_ir_config_parameter/README.rst @@ -14,13 +14,13 @@ Server Environment Ir Config Parameter :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github - :target: https://github.com/OCA/server-env/tree/12.0/server_environment_ir_config_parameter + :target: https://github.com/OCA/server-env/tree/13.0/server_environment_ir_config_parameter :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-12-0/server-env-12-0-server_environment_ir_config_parameter + :target: https://translation.odoo-community.org/projects/server-env-13-0/server-env-13-0-server_environment_ir_config_parameter :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png - :target: https://runbot.odoo-community.org/runbot/254/12.0 + :target: https://runbot.odoo-community.org/runbot/254/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -73,7 +73,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -111,6 +111,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 `_ project on GitHub. +This module is part of the `OCA/server-env `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/server_environment_ir_config_parameter/__manifest__.py b/server_environment_ir_config_parameter/__manifest__.py index 072990d..54a7d5c 100644 --- a/server_environment_ir_config_parameter/__manifest__.py +++ b/server_environment_ir_config_parameter/__manifest__.py @@ -2,14 +2,12 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { - 'name': 'Server Environment Ir Config Parameter', - 'summary': """ + "name": "Server Environment Ir Config Parameter", + "summary": """ Override System Parameters from server environment file""", - 'version': '13.0.1.0.0', - 'license': 'AGPL-3', - 'author': 'ACSONE SA/NV, Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/server-env/', - 'depends': [ - 'server_environment', - ], + "version": "13.0.1.0.0", + "license": "AGPL-3", + "author": "ACSONE SA/NV, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/server-env/", + "depends": ["server_environment"], } diff --git a/server_environment_ir_config_parameter/i18n/de.po b/server_environment_ir_config_parameter/i18n/de.po index 5625ccc..62e4979 100644 --- a/server_environment_ir_config_parameter/i18n/de.po +++ b/server_environment_ir_config_parameter/i18n/de.po @@ -19,7 +19,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: server_environment_ir_config_parameter -#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22 +#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" msgstr "" diff --git a/server_environment_ir_config_parameter/i18n/es.po b/server_environment_ir_config_parameter/i18n/es.po index 7f53f15..c7ea92e 100644 --- a/server_environment_ir_config_parameter/i18n/es.po +++ b/server_environment_ir_config_parameter/i18n/es.po @@ -19,7 +19,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: server_environment_ir_config_parameter -#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22 +#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" msgstr "" diff --git a/server_environment_ir_config_parameter/i18n/it.po b/server_environment_ir_config_parameter/i18n/it.po index 51b0a6f..4c61c5e 100644 --- a/server_environment_ir_config_parameter/i18n/it.po +++ b/server_environment_ir_config_parameter/i18n/it.po @@ -19,7 +19,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: server_environment_ir_config_parameter -#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22 +#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" msgstr "" diff --git a/server_environment_ir_config_parameter/i18n/nl_NL.po b/server_environment_ir_config_parameter/i18n/nl_NL.po index 8e68688..9ad1b47 100644 --- a/server_environment_ir_config_parameter/i18n/nl_NL.po +++ b/server_environment_ir_config_parameter/i18n/nl_NL.po @@ -20,7 +20,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" #. module: server_environment_ir_config_parameter -#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22 +#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" msgstr "sleutel %s is leeg 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 2381689..84161e6 100644 --- a/server_environment_ir_config_parameter/i18n/ro.po +++ b/server_environment_ir_config_parameter/i18n/ro.po @@ -20,7 +20,7 @@ msgstr "" "2:1));\n" #. module: server_environment_ir_config_parameter -#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22 +#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" msgstr "" 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 a17f0d0..5440781 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 @@ -1,12 +1,12 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * server_environment_ir_config_parameter +# * server_environment_ir_config_parameter # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 13.0\n" "Report-Msgid-Bugs-To: \n" -"Last-Translator: <>\n" +"Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -14,7 +14,7 @@ msgstr "" "Plural-Forms: \n" #. module: server_environment_ir_config_parameter -#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22 +#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:0 #, python-format msgid "Key %s is empty in server_environment_file" msgstr "" @@ -23,4 +23,3 @@ msgstr "" #: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter msgid "System Parameter" msgstr "" - 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 ab44ec9..2ad3eae 100644 --- a/server_environment_ir_config_parameter/models/ir_config_parameter.py +++ b/server_environment_ir_config_parameter/models/ir_config_parameter.py @@ -1,17 +1,17 @@ # 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, models from odoo.exceptions import UserError + from odoo.addons.server_environment import serv_config - -SECTION = 'ir.config_parameter' +SECTION = "ir.config_parameter" class IrConfigParameter(models.Model): - _inherit = 'ir.config_parameter' + _inherit = "ir.config_parameter" @api.model def get_param(self, key, default=False): @@ -19,9 +19,9 @@ class IrConfigParameter(models.Model): if serv_config.has_option(SECTION, key): cvalue = serv_config.get(SECTION, key) if not cvalue: - raise UserError(_("Key %s is empty in " - "server_environment_file") % - (key, )) + raise UserError( + _("Key %s is empty in " "server_environment_file") % (key,) + ) if cvalue != value: # we write in db on first access; # should we have preloaded values in database at, @@ -35,7 +35,7 @@ class IrConfigParameter(models.Model): @api.model def create(self, vals): - key = vals.get('key') + key = vals.get("key") if serv_config.has_option(SECTION, key): # enforce value from config file vals = dict(vals, value=serv_config.get(SECTION, key)) @@ -43,7 +43,7 @@ class IrConfigParameter(models.Model): def write(self, vals): for rec in self: - key = vals.get('key') or rec.key + key = vals.get("key") or rec.key if serv_config.has_option(SECTION, key): # enforce value from config file newvals = dict(vals, value=serv_config.get(SECTION, key)) diff --git a/server_environment_ir_config_parameter/readme/CONFIGURE.rst b/server_environment_ir_config_parameter/readme/CONFIGURE.rst index ce786cb..03cccf5 100644 --- a/server_environment_ir_config_parameter/readme/CONFIGURE.rst +++ b/server_environment_ir_config_parameter/readme/CONFIGURE.rst @@ -14,4 +14,4 @@ For example you can use this module in combination with web_environment_ribbon: .. code:: [ir.config_parameter] - ribbon.name=DEV \ No newline at end of file + ribbon.name=DEV diff --git a/server_environment_ir_config_parameter/readme/CREDITS.rst b/server_environment_ir_config_parameter/readme/CREDITS.rst index e8134ce..c08e96d 100644 --- a/server_environment_ir_config_parameter/readme/CREDITS.rst +++ b/server_environment_ir_config_parameter/readme/CREDITS.rst @@ -1,2 +1,2 @@ This module is maintained by: -* Odoo Community Association \ No newline at end of file +* Odoo Community Association diff --git a/server_environment_ir_config_parameter/readme/DESCRIPTION.rst b/server_environment_ir_config_parameter/readme/DESCRIPTION.rst index 141459e..8ffc000 100644 --- a/server_environment_ir_config_parameter/readme/DESCRIPTION.rst +++ b/server_environment_ir_config_parameter/readme/DESCRIPTION.rst @@ -1 +1 @@ -Override System Parameters from server environment file. \ No newline at end of file +Override System Parameters from server environment file. diff --git a/server_environment_ir_config_parameter/readme/ROADMAP.rst b/server_environment_ir_config_parameter/readme/ROADMAP.rst index 42a26d8..27b704a 100644 --- a/server_environment_ir_config_parameter/readme/ROADMAP.rst +++ b/server_environment_ir_config_parameter/readme/ROADMAP.rst @@ -1,4 +1,4 @@ When the user modifies System Parameters that are defined in the config file, the changes are ignored. It would be nice to display which system parameters come from the config file and possibly make their key and value -readonly in the user interface. \ No newline at end of file +readonly in the user interface. diff --git a/server_environment_ir_config_parameter/readme/USAGE.rst b/server_environment_ir_config_parameter/readme/USAGE.rst index 300775c..44c0bc6 100644 --- a/server_environment_ir_config_parameter/readme/USAGE.rst +++ b/server_environment_ir_config_parameter/readme/USAGE.rst @@ -1,2 +1,2 @@ Before using this module, you must be familiar with the -server_environment module. \ No newline at end of file +server_environment module. diff --git a/server_environment_ir_config_parameter/static/description/index.html b/server_environment_ir_config_parameter/static/description/index.html index 75e68ce..4a014f6 100644 --- a/server_environment_ir_config_parameter/static/description/index.html +++ b/server_environment_ir_config_parameter/static/description/index.html @@ -367,7 +367,7 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/server-env Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/server-env Translate me on Weblate Try me on Runbot

Override System Parameters from server environment file.

Table of contents

@@ -418,7 +418,7 @@ readonly in the user interface.

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -449,7 +449,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome

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 project on GitHub.

+

This module is part of the OCA/server-env project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/server_environment_ir_config_parameter/tests/config_param_test.xml b/server_environment_ir_config_parameter/tests/config_param_test.xml index 61303a8..29d2a99 100644 --- a/server_environment_ir_config_parameter/tests/config_param_test.xml +++ b/server_environment_ir_config_parameter/tests/config_param_test.xml @@ -1,6 +1,6 @@ - - ircp_from_config - value_from_xml - + + ircp_from_config + value_from_xml + diff --git a/server_environment_ir_config_parameter/tests/test_server_environment_ircp.py b/server_environment_ir_config_parameter/tests/test_server_environment_ircp.py index 8843f79..b8a0337 100644 --- a/server_environment_ir_config_parameter/tests/test_server_environment_ircp.py +++ b/server_environment_ir_config_parameter/tests/test_server_environment_ircp.py @@ -2,79 +2,103 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.exceptions import UserError -from odoo.tests import common -from odoo.tools import convert_file from odoo.modules.module import get_resource_path +from odoo.tools import convert_file + +from odoo.addons.server_environment.tests.common import ServerEnvironmentCase + +from ..models import ir_config_parameter -class TestEnv(common.TransactionCase): - +class TestEnv(ServerEnvironmentCase): def setUp(self): super().setUp() - self.ICP = self.env['ir.config_parameter'] + self.ICP = self.env["ir.config_parameter"] + self.env_config = ( + "[ir.config_parameter]\n" "ircp_from_config=config_value\n" "ircp_empty=\n" + ) def _load_xml(self, module, filepath): convert_file( - self.env.cr, module, + self.env.cr, + module, get_resource_path(module, filepath), - {}, mode='init', noupdate=False, kind='test') + {}, + mode="init", + noupdate=False, + kind="test", + ) def test_get_param(self): """ Get system parameter from config """ - # it's not in db - res = self.ICP.search([('key', '=', 'ircp_from_config')]) - self.assertFalse(res) - # read so it's created in db - value = self.ICP.get_param('ircp_from_config') - self.assertEqual(value, 'config_value') - # now it's in db - res = self.ICP.search([('key', '=', 'ircp_from_config')]) - self.assertEqual(len(res), 1) - self.assertEqual(res.value, 'config_value') + with self.load_config( + public=self.env_config, serv_config_class=ir_config_parameter + ): + # it's not in db + res = self.ICP.search([("key", "=", "ircp_from_config")]) + self.assertFalse(res) + # read so it's created in db + value = self.ICP.get_param("ircp_from_config") + self.assertEqual(value, "config_value") + # now it's in db + res = self.ICP.search([("key", "=", "ircp_from_config")]) + self.assertEqual(len(res), 1) + self.assertEqual(res.value, "config_value") def test_set_param_1(self): """ We can't set parameters that are in config file """ - # when creating, the value is overridden by config file - self.ICP.set_param('ircp_from_config', 'new_value') - value = self.ICP.get_param('ircp_from_config') - self.assertEqual(value, 'config_value') - # when writing, the value is overridden by config file - res = self.ICP.search([('key', '=', 'ircp_from_config')]) - self.assertEqual(len(res), 1) - res.write({'value': 'new_value'}) - value = self.ICP.get_param('ircp_from_config') - self.assertEqual(value, 'config_value') - # unlink works normally... - res = self.ICP.search([('key', '=', 'ircp_from_config')]) - self.assertEqual(len(res), 1) - res.unlink() - res = self.ICP.search([('key', '=', 'ircp_from_config')]) - self.assertEqual(len(res), 0) - # but the value is recreated when getting param again - value = self.ICP.get_param('ircp_from_config') - self.assertEqual(value, 'config_value') - res = self.ICP.search([('key', '=', 'ircp_from_config')]) - self.assertEqual(len(res), 1) + with self.load_config( + public=self.env_config, serv_config_class=ir_config_parameter + ): + # when creating, the value is overridden by config file + self.ICP.set_param("ircp_from_config", "new_value") + value = self.ICP.get_param("ircp_from_config") + self.assertEqual(value, "config_value") + # when writing, the value is overridden by config file + res = self.ICP.search([("key", "=", "ircp_from_config")]) + self.assertEqual(len(res), 1) + res.write({"value": "new_value"}) + value = self.ICP.get_param("ircp_from_config") + self.assertEqual(value, "config_value") + # unlink works normally... + res = self.ICP.search([("key", "=", "ircp_from_config")]) + self.assertEqual(len(res), 1) + res.unlink() + res = self.ICP.search([("key", "=", "ircp_from_config")]) + self.assertEqual(len(res), 0) + # but the value is recreated when getting param again + value = self.ICP.get_param("ircp_from_config") + self.assertEqual(value, "config_value") + res = self.ICP.search([("key", "=", "ircp_from_config")]) + self.assertEqual(len(res), 1) def test_set_param_2(self): """ We can set parameters that are not in config file """ - self.ICP.set_param('some.param', 'new_value') - self.assertEqual(self.ICP.get_param('some.param'), 'new_value') - res = self.ICP.search([('key', '=', 'some.param')]) - res.unlink() - res = self.ICP.search([('key', '=', 'some.param')]) - self.assertFalse(res) + with self.load_config( + public=self.env_config, serv_config_class=ir_config_parameter + ): + self.ICP.set_param("some.param", "new_value") + self.assertEqual(self.ICP.get_param("some.param"), "new_value") + res = self.ICP.search([("key", "=", "some.param")]) + res.unlink() + res = self.ICP.search([("key", "=", "some.param")]) + self.assertFalse(res) def test_empty(self): """ Empty config values cause error """ - with self.assertRaises(UserError): - self.ICP.get_param('ircp_empty') - self.assertEqual(self.ICP.get_param('ircp_nonexistant'), False) + with self.load_config( + public=self.env_config, serv_config_class=ir_config_parameter + ): + with self.assertRaises(UserError): + self.ICP.get_param("ircp_empty") + self.assertEqual(self.ICP.get_param("ircp_nonexistant"), False) def test_override_xmldata(self): - self._load_xml( - 'server_environment_ir_config_parameter', - 'tests/config_param_test.xml' - ) - value = self.ICP.get_param('ircp_from_config') - self.assertEqual(value, 'config_value') + with self.load_config( + public=self.env_config, serv_config_class=ir_config_parameter + ): + self._load_xml( + "server_environment_ir_config_parameter", "tests/config_param_test.xml" + ) + value = self.ICP.get_param("ircp_from_config") + self.assertEqual(value, "config_value")