[MIG] fix tests

Manual forward port of 11.0 migration commit by Thierry Ducrest.
This commit is contained in:
Thierry Ducrest 2018-11-15 15:39:30 +01:00 committed by Marcos Oitaben
parent 0c2ea10038
commit ae201ae666
14 changed files with 77 additions and 53 deletions

View File

@ -13,14 +13,14 @@ Server Environment Ir Config Parameter
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png .. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/12.0/server_environment_ir_config_parameter :target: https://github.com/OCA/server-env/tree/12.0/server_environment_ir_config_parameter
:alt: OCA/server-tools :alt: OCA/server-env
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-server_environment_ir_config_parameter :target: https://translation.odoo-community.org/projects/server-env-12-0/server-env-12-0-server_environment_ir_config_parameter
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/149/12.0 :target: https://runbot.odoo-community.org/runbot/254/12.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -70,10 +70,10 @@ readonly in the user interface.
Bug Tracker Bug Tracker
=========== ===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_. 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. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20server_environment_ir_config_parameter%0Aversion:%2012.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_ir_config_parameter%0Aversion:%2012.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. Do not contact contributors directly about support or help with technical issues.
@ -89,6 +89,7 @@ Contributors
~~~~~~~~~~~~ ~~~~~~~~~~~~
* Stéphane Bidoul <stephane.bidoul@acsone.eu> (https://acsone.eu) * 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) * Gilles Meyomesse <gilles.meyomesse@acsone.eu> (https://acsone.eu)
Other credits Other credits
@ -110,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 mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/12.0/server_environment_ir_config_parameter>`_ project on GitHub. This module is part of the `OCA/server-env <https://github.com/OCA/server-env/tree/12.0/server_environment_ir_config_parameter>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1,4 +1,4 @@
# Copyright 2016 ACSONE SA/NV # Copyright 2016-2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
@ -8,7 +8,7 @@
'version': '12.0.1.0.0', 'version': '12.0.1.0.0',
'license': 'AGPL-3', 'license': 'AGPL-3',
'author': 'ACSONE SA/NV, Odoo Community Association (OCA)', 'author': 'ACSONE SA/NV, Odoo Community Association (OCA)',
'website': 'https://odoo-community.org/', 'website': 'https://github.com/OCA/server-env/',
'depends': [ 'depends': [
'server_environment', 'server_environment',
], ],

View File

@ -19,12 +19,15 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:23 #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22
#, python-format #, python-format
msgid "Key %s is empty in server_environment_file" msgid "Key %s is empty in server_environment_file"
msgstr "" msgstr ""
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter #: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter
msgid "ir.config_parameter" msgid "System Parameter"
msgstr "ir.config_parameter" msgstr ""
#~ msgid "ir.config_parameter"
#~ msgstr "ir.config_parameter"

View File

@ -19,12 +19,15 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:23 #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22
#, python-format #, python-format
msgid "Key %s is empty in server_environment_file" msgid "Key %s is empty in server_environment_file"
msgstr "" msgstr ""
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter #: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter
msgid "ir.config_parameter" msgid "System Parameter"
msgstr "ir.config_parameter" msgstr ""
#~ msgid "ir.config_parameter"
#~ msgstr "ir.config_parameter"

View File

@ -19,12 +19,15 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:23 #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22
#, python-format #, python-format
msgid "Key %s is empty in server_environment_file" msgid "Key %s is empty in server_environment_file"
msgstr "" msgstr ""
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter #: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter
msgid "ir.config_parameter" msgid "System Parameter"
msgstr "ir.config_parameter" msgstr ""
#~ msgid "ir.config_parameter"
#~ msgstr "ir.config_parameter"

View File

@ -20,12 +20,15 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:23 #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22
#, python-format #, python-format
msgid "Key %s is empty in server_environment_file" msgid "Key %s is empty in server_environment_file"
msgstr "sleutel %s is leeg in server_environment_file" msgstr "sleutel %s is leeg in server_environment_file"
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter #: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter
msgid "ir.config_parameter" msgid "System Parameter"
msgstr "ir.config_parameter" msgstr ""
#~ msgid "ir.config_parameter"
#~ msgstr "ir.config_parameter"

View File

@ -20,12 +20,15 @@ msgstr ""
"2:1));\n" "2:1));\n"
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:23 #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22
#, python-format #, python-format
msgid "Key %s is empty in server_environment_file" msgid "Key %s is empty in server_environment_file"
msgstr "" msgstr ""
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter #: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter
msgid "ir.config_parameter" msgid "System Parameter"
msgstr "ir.config_parameter" msgstr ""
#~ msgid "ir.config_parameter"
#~ msgstr "ir.config_parameter"

View File

@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 10.0\n" "Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
@ -14,13 +14,13 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:23 #: code:addons/server_environment_ir_config_parameter/models/ir_config_parameter.py:22
#, python-format #, python-format
msgid "Key %s is empty in server_environment_file" msgid "Key %s is empty in server_environment_file"
msgstr "" msgstr ""
#. module: server_environment_ir_config_parameter #. module: server_environment_ir_config_parameter
#: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter #: model:ir.model,name:server_environment_ir_config_parameter.model_ir_config_parameter
msgid "ir.config_parameter" msgid "System Parameter"
msgstr "" msgstr ""

View File

@ -1,4 +1,4 @@
# Copyright 2016 ACSONE SA/NV # Copyright 2016-2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, models, _ from odoo import api, models, _
@ -15,7 +15,7 @@ class IrConfigParameter(models.Model):
@api.model @api.model
def get_param(self, key, default=False): def get_param(self, key, default=False):
value = super(IrConfigParameter, self).get_param(key, default=None) value = super().get_param(key, default=None)
if serv_config.has_option(SECTION, key): if serv_config.has_option(SECTION, key):
cvalue = serv_config.get(SECTION, key) cvalue = serv_config.get(SECTION, key)
if not cvalue: if not cvalue:
@ -39,7 +39,7 @@ class IrConfigParameter(models.Model):
if serv_config.has_option(SECTION, key): if serv_config.has_option(SECTION, key):
# enforce value from config file # enforce value from config file
vals = dict(vals, value=serv_config.get(SECTION, key)) vals = dict(vals, value=serv_config.get(SECTION, key))
return super(IrConfigParameter, self).create(vals) return super().create(vals)
@api.multi @api.multi
def write(self, vals): def write(self, vals):
@ -50,5 +50,5 @@ class IrConfigParameter(models.Model):
newvals = dict(vals, value=serv_config.get(SECTION, key)) newvals = dict(vals, value=serv_config.get(SECTION, key))
else: else:
newvals = vals newvals = vals
super(IrConfigParameter, rec).write(newvals) super().write(newvals)
return True return True

View File

@ -1,2 +1,3 @@
* Stéphane Bidoul <stephane.bidoul@acsone.eu> (https://acsone.eu) * 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) * Gilles Meyomesse <gilles.meyomesse@acsone.eu> (https://acsone.eu)

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" /> <meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>Server Environment Ir Config Parameter</title> <title>Server Environment Ir Config Parameter</title>
<style type="text/css"> <style type="text/css">
@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-tools/tree/12.0/server_environment_ir_config_parameter"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-server_environment_ir_config_parameter"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/149/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-env/tree/12.0/server_environment_ir_config_parameter"><img alt="OCA/server-env" src="https://img.shields.io/badge/github-OCA%2Fserver--env-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-env-12-0/server-env-12-0-server_environment_ir_config_parameter"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/254/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>Override System Parameters from server environment file.</p> <p>Override System Parameters from server environment file.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents"> <div class="contents local topic" id="contents">
@ -415,10 +415,10 @@ readonly in the user interface.</p>
</div> </div>
<div class="section" id="bug-tracker"> <div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1> <h1><a class="toc-backref" href="#id4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-env/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20server_environment_ir_config_parameter%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/server-env/issues/new?body=module:%20server_environment_ir_config_parameter%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -433,6 +433,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<h2><a class="toc-backref" href="#id7">Contributors</a></h2> <h2><a class="toc-backref" href="#id7">Contributors</a></h2>
<ul class="simple"> <ul class="simple">
<li>Stéphane Bidoul &lt;<a class="reference external" href="mailto:stephane.bidoul&#64;acsone.eu">stephane.bidoul&#64;acsone.eu</a>&gt; (<a class="reference external" href="https://acsone.eu">https://acsone.eu</a>)</li> <li>Stéphane Bidoul &lt;<a class="reference external" href="mailto:stephane.bidoul&#64;acsone.eu">stephane.bidoul&#64;acsone.eu</a>&gt; (<a class="reference external" href="https://acsone.eu">https://acsone.eu</a>)</li>
<li>Thierry Ducrest &lt;<a class="reference external" href="mailto:thierry.ducrest&#64;camptocamp.com">thierry.ducrest&#64;camptocamp.com</a>&gt;</li>
<li>Gilles Meyomesse &lt;<a class="reference external" href="mailto:gilles.meyomesse&#64;acsone.eu">gilles.meyomesse&#64;acsone.eu</a>&gt; (<a class="reference external" href="https://acsone.eu">https://acsone.eu</a>)</li> <li>Gilles Meyomesse &lt;<a class="reference external" href="mailto:gilles.meyomesse&#64;acsone.eu">gilles.meyomesse&#64;acsone.eu</a>&gt; (<a class="reference external" href="https://acsone.eu">https://acsone.eu</a>)</li>
</ul> </ul>
</div> </div>
@ -448,7 +449,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/12.0/server_environment_ir_config_parameter">OCA/server-tools</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-env/tree/12.0/server_environment_ir_config_parameter">OCA/server-env</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@ -0,0 +1,6 @@
<odoo>
<record model="ir.config_parameter" id="some_record_id">
<field name="key">ircp_from_config</field>
<field name="value">value_from_xml</field>
</record>
</odoo>

View File

@ -1,19 +1,24 @@
# Copyright 2016 ACSONE SA/NV # Copyright 2016-2018 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from cStringIO import StringIO
from odoo.exceptions import UserError from odoo.exceptions import UserError
from odoo.tests import common from odoo.tests import common
from odoo.tools import convert from odoo.tools import convert_file
from odoo.modules.module import get_resource_path
class TestEnv(common.TransactionCase): class TestEnv(common.TransactionCase):
def setUp(self): def setUp(self):
super(TestEnv, self).setUp() super().setUp()
self.ICP = self.env['ir.config_parameter'] self.ICP = self.env['ir.config_parameter']
def _load_xml(self, module, filepath):
convert_file(
self.env.cr, module,
get_resource_path(module, filepath),
{}, mode='init', noupdate=False, kind='test')
def test_get_param(self): def test_get_param(self):
""" Get system parameter from config """ """ Get system parameter from config """
# it's not in db # it's not in db
@ -67,14 +72,9 @@ class TestEnv(common.TransactionCase):
self.assertEqual(self.ICP.get_param('ircp_nonexistant'), False) self.assertEqual(self.ICP.get_param('ircp_nonexistant'), False)
def test_override_xmldata(self): def test_override_xmldata(self):
xml = """<odoo> self._load_xml(
<data> 'server_environment_ir_config_parameter',
<record model="ir.config_parameter" id="some_record_id"> 'tests/config_param_test.xml'
<field name="key">ircp_from_config</field> )
<field name="value">value_from_xml</field>
</record>
</data>
</odoo>"""
convert.convert_xml_import(self.env.cr, 'testmodule', StringIO(xml))
value = self.ICP.get_param('ircp_from_config') value = self.ICP.get_param('ircp_from_config')
self.assertEqual(value, 'config_value') self.assertEqual(value, 'config_value')