[FIX] base_external_system. Solve test error.

Testing fingerprint, with ignore_finger_print set to False, caused an error, because it would first set
ignore_fingerprint to False, then validate, never getting to actually setting the fingerprint, causing the
following stacktrace:
Traceback (most recent call last):

  File "/home/travis/build/OCA/server-backend/base_external_system/tests/test_external_system.py", line 28, in test_check_fingerprint_allowed

    self.record.write({"ignore_fingerprint": False, "fingerprint": "Data"})

  File "/home/travis/odoo-13.0/odoo/models.py", line 3573, in write

    fields[0].determine_inverse(real_recs)

  File "/home/travis/odoo-13.0/odoo/fields.py", line 1122, in determine_inverse

    self.inverse(records)

  File "/home/travis/odoo-13.0/odoo/fields.py", line 594, in _inverse_related

    target[field.name] = record_value[record]

  File "/home/travis/odoo-13.0/odoo/models.py", line 5629, in __setitem__

    return self._fields[key].__set__(self, value)

  File "/home/travis/odoo-13.0/odoo/fields.py", line 1087, in __set__

    records.write({self.name: write_value})

  File "/home/travis/odoo-13.0/odoo/models.py", line 3568, in write

    real_recs._validate_fields(set(vals) - set(inverse_fields))

  File "/home/travis/odoo-13.0/odoo/models.py", line 1176, in _validate_fields

    check(self)
This commit is contained in:
Ronald Portier
2020-08-21 12:09:22 +02:00
committed by ntsirintanis
parent 5f08203852
commit 748345c0b2
4 changed files with 41 additions and 23 deletions

View File

@@ -14,13 +14,13 @@ Base External System
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3 :alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github
:target: https://github.com/OCA/server-backend/tree/12.0/base_external_system :target: https://github.com/OCA/server-backend/tree/13.0/base_external_system
:alt: OCA/server-backend :alt: OCA/server-backend
.. |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-backend-12-0/server-backend-12-0-base_external_system :target: https://translation.odoo-community.org/projects/server-backend-13-0/server-backend-13-0-base_external_system
: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/253/12.0 :target: https://runbot.odoo-community.org/runbot/253/13.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -85,7 +85,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-backend/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-backend/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-backend/issues/new?body=module:%20base_external_system%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/server-backend/issues/new?body=module:%20base_external_system%0Aversion:%2013.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.
@@ -102,6 +102,7 @@ Contributors
* Dave Lasley <dave@laslabs.com> * Dave Lasley <dave@laslabs.com>
* Alexandre Díaz <alexandre.diaz@tecnativa.com> * Alexandre Díaz <alexandre.diaz@tecnativa.com>
* Ronald Portier <ronald@therp.nl>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@@ -116,6 +117,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-backend <https://github.com/OCA/server-backend/tree/12.0/base_external_system>`_ project on GitHub. This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/13.0/base_external_system>`_ 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

@@ -4,9 +4,9 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 12.0\n" "Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
@@ -28,7 +28,7 @@ msgid "Companies"
msgstr "" msgstr ""
#. module: base_external_system #. module: base_external_system
#: sql_constraint:external.system:0 #: model:ir.model.constraint,message:base_external_system.constraint_external_system_name_uniq
msgid "Connection name must be unique." msgid "Connection name must be unique."
msgstr "" msgstr ""
@@ -85,7 +85,7 @@ msgid "Fingerprint"
msgstr "" msgstr ""
#. module: base_external_system #. module: base_external_system
#: code:addons/base_external_system/models/external_system.py:90 #: code:addons/base_external_system/models/external_system.py:0
#, python-format #, python-format
msgid "Fingerprint cannot be empty when Ignore Fingerprint is not checked." msgid "Fingerprint cannot be empty when Ignore Fingerprint is not checked."
msgstr "" msgstr ""
@@ -204,7 +204,9 @@ msgstr ""
#: model:ir.model.fields,help:base_external_system.field_external_system__ignore_fingerprint #: model:ir.model.fields,help:base_external_system.field_external_system__ignore_fingerprint
#: model:ir.model.fields,help:base_external_system.field_external_system_adapter__ignore_fingerprint #: model:ir.model.fields,help:base_external_system.field_external_system_adapter__ignore_fingerprint
#: model:ir.model.fields,help:base_external_system.field_external_system_os__ignore_fingerprint #: model:ir.model.fields,help:base_external_system.field_external_system_os__ignore_fingerprint
msgid "Set this to `True` in order to ignore an invalid/unknown fingerprint from the system." msgid ""
"Set this to `True` in order to ignore an invalid/unknown fingerprint from "
"the system."
msgstr "" msgstr ""
#. module: base_external_system #. module: base_external_system
@@ -226,7 +228,7 @@ msgid "Test Connection"
msgstr "" msgstr ""
#. module: base_external_system #. module: base_external_system
#: code:addons/base_external_system/models/external_system_adapter.py:70 #: code:addons/base_external_system/models/external_system_adapter.py:0
#, python-format #, python-format
msgid "The connection was a success." msgid "The connection was a success."
msgstr "" msgstr ""
@@ -249,28 +251,36 @@ msgstr ""
#: model:ir.model.fields,help:base_external_system.field_external_system__fingerprint #: model:ir.model.fields,help:base_external_system.field_external_system__fingerprint
#: model:ir.model.fields,help:base_external_system.field_external_system_adapter__fingerprint #: model:ir.model.fields,help:base_external_system.field_external_system_adapter__fingerprint
#: model:ir.model.fields,help:base_external_system.field_external_system_os__fingerprint #: model:ir.model.fields,help:base_external_system.field_external_system_os__fingerprint
msgid "This is the fingerprint that is advertised by this system in order to validate its identity." msgid ""
"This is the fingerprint that is advertised by this system in order to "
"validate its identity."
msgstr "" msgstr ""
#. module: base_external_system #. module: base_external_system
#: model:ir.model.fields,help:base_external_system.field_external_system__interface #: model:ir.model.fields,help:base_external_system.field_external_system__interface
#: model:ir.model.fields,help:base_external_system.field_external_system_adapter__interface #: model:ir.model.fields,help:base_external_system.field_external_system_adapter__interface
#: model:ir.model.fields,help:base_external_system.field_external_system_os__interface #: model:ir.model.fields,help:base_external_system.field_external_system_os__interface
msgid "This is the interface that this system represents. It is created automatically upon creation of the external system." msgid ""
"This is the interface that this system represents. It is created "
"automatically upon creation of the external system."
msgstr "" msgstr ""
#. module: base_external_system #. module: base_external_system
#: model:ir.model.fields,help:base_external_system.field_external_system__password #: model:ir.model.fields,help:base_external_system.field_external_system__password
#: model:ir.model.fields,help:base_external_system.field_external_system_adapter__password #: model:ir.model.fields,help:base_external_system.field_external_system_adapter__password
#: model:ir.model.fields,help:base_external_system.field_external_system_os__password #: model:ir.model.fields,help:base_external_system.field_external_system_os__password
msgid "This is the password that is used for authenticating to this system, if applicable." msgid ""
"This is the password that is used for authenticating to this system, if "
"applicable."
msgstr "" msgstr ""
#. module: base_external_system #. module: base_external_system
#: model:ir.model.fields,help:base_external_system.field_external_system__private_key_password #: model:ir.model.fields,help:base_external_system.field_external_system__private_key_password
#: model:ir.model.fields,help:base_external_system.field_external_system_adapter__private_key_password #: model:ir.model.fields,help:base_external_system.field_external_system_adapter__private_key_password
#: model:ir.model.fields,help:base_external_system.field_external_system_os__private_key_password #: model:ir.model.fields,help:base_external_system.field_external_system_os__private_key_password
msgid "This is the password to unlock the private key that was provided for this sytem." msgid ""
"This is the password to unlock the private key that was provided for this "
"sytem."
msgstr "" msgstr ""
#. module: base_external_system #. module: base_external_system
@@ -284,14 +294,18 @@ msgstr ""
#: model:ir.model.fields,help:base_external_system.field_external_system__private_key #: model:ir.model.fields,help:base_external_system.field_external_system__private_key
#: model:ir.model.fields,help:base_external_system.field_external_system_adapter__private_key #: model:ir.model.fields,help:base_external_system.field_external_system_adapter__private_key
#: model:ir.model.fields,help:base_external_system.field_external_system_os__private_key #: model:ir.model.fields,help:base_external_system.field_external_system_os__private_key
msgid "This is the private key that is used for authenticating to this system, if applicable." msgid ""
"This is the private key that is used for authenticating to this system, if "
"applicable."
msgstr "" msgstr ""
#. module: base_external_system #. module: base_external_system
#: model:ir.model.fields,help:base_external_system.field_external_system__username #: model:ir.model.fields,help:base_external_system.field_external_system__username
#: model:ir.model.fields,help:base_external_system.field_external_system_adapter__username #: model:ir.model.fields,help:base_external_system.field_external_system_adapter__username
#: model:ir.model.fields,help:base_external_system.field_external_system_os__username #: model:ir.model.fields,help:base_external_system.field_external_system_os__username
msgid "This is the username that is used for authenticating to this system, if applicable." msgid ""
"This is the username that is used for authenticating to this system, if "
"applicable."
msgstr "" msgstr ""
#. module: base_external_system #. module: base_external_system
@@ -301,4 +315,3 @@ msgstr ""
#: model_terms:ir.ui.view,arch_db:base_external_system.external_system_view_search #: model_terms:ir.ui.view,arch_db:base_external_system.external_system_view_search
msgid "Username" msgid "Username"
msgstr "" msgstr ""

View File

@@ -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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-backend/tree/12.0/base_external_system"><img alt="OCA/server-backend" src="https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-backend-12-0/server-backend-12-0-base_external_system"><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/253/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/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/server-backend/tree/13.0/base_external_system"><img alt="OCA/server-backend" src="https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-backend-13-0/server-backend-13-0-base_external_system"><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/253/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module provides an interface/adapter mechanism for the definition of remote <p>This module provides an interface/adapter mechanism for the definition of remote
systems.</p> systems.</p>
<p>Note that this module stores everything in plain text. In the interest of security, <p>Note that this module stores everything in plain text. In the interest of security,
@@ -431,7 +431,7 @@ to be defined if the connection destroys itself.</li>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-backend/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-backend/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-backend/issues/new?body=module:%20base_external_system%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-backend/issues/new?body=module:%20base_external_system%0Aversion:%2013.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">
@@ -447,6 +447,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<ul class="simple"> <ul class="simple">
<li>Dave Lasley &lt;<a class="reference external" href="mailto:dave&#64;laslabs.com">dave&#64;laslabs.com</a>&gt;</li> <li>Dave Lasley &lt;<a class="reference external" href="mailto:dave&#64;laslabs.com">dave&#64;laslabs.com</a>&gt;</li>
<li>Alexandre Díaz &lt;<a class="reference external" href="mailto:alexandre.diaz&#64;tecnativa.com">alexandre.diaz&#64;tecnativa.com</a>&gt;</li> <li>Alexandre Díaz &lt;<a class="reference external" href="mailto:alexandre.diaz&#64;tecnativa.com">alexandre.diaz&#64;tecnativa.com</a>&gt;</li>
<li>Ronald Portier &lt;<a class="reference external" href="mailto:ronald&#64;therp.nl">ronald&#64;therp.nl</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@@ -456,7 +457,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-backend/tree/12.0/base_external_system">OCA/server-backend</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-backend/tree/13.0/base_external_system">OCA/server-backend</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

@@ -25,7 +25,10 @@ class TestExternalSystem(Common):
def test_check_fingerprint_allowed(self): def test_check_fingerprint_allowed(self):
"""It should not raise a validation error if there is a fingerprint.""" """It should not raise a validation error if there is a fingerprint."""
self.record.write({"ignore_fingerprint": False, "fingerprint": "Data"}) # In Odoo 13.0, due to the way inverse records (models inherited from)
# are handled, setting both fields at the same time causes an error.
self.record.write({"fingerprint": "Data"})
self.record.write({"ignore_fingerprint": False})
self.assertTrue(True) self.assertTrue(True)
def test_client(self): def test_client(self):