Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exclude: |
^base_rest_auth_user_service/|
^base_rest_datamodel/|
^base_rest_demo/|
^datamodel/|
^graphql_base/|
^graphql_demo/|
^model_serializer/|
Expand Down
8 changes: 4 additions & 4 deletions datamodel/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Datamodel
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github
:target: https://github.com/OCA/rest-framework/tree/14.0/datamodel
:target: https://github.com/OCA/rest-framework/tree/15.0/datamodel
:alt: OCA/rest-framework
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/rest-framework-14-0/rest-framework-14-0-datamodel
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/271/14.0
:target: https://runbot.odoo-community.org/runbot/271/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -129,7 +129,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/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 <https://github.com/OCA/rest-framework/issues/new?body=module:%20datamodel%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/rest-framework/issues/new?body=module:%20datamodel%0Aversion:%2015.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.

Expand Down Expand Up @@ -170,6 +170,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-lmignon|

This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/14.0/datamodel>`_ project on GitHub.
This module is part of the `OCA/rest-framework <https://github.com/OCA/rest-framework/tree/15.0/datamodel>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions datamodel/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"summary": """
This addon allows you to define simple data models supporting
serialization/deserialization""",
"version": "14.0.3.0.4",
"version": "15.0.1.0.0",
"license": "LGPL-3",
"development_status": "Beta",
"author": "ACSONE SA/NV, " "Odoo Community Association (OCA)",
Expand All @@ -16,5 +16,5 @@
"data": [],
"demo": [],
"external_dependencies": {"python": ["marshmallow", "marshmallow-objects>=2.0.0"]},
"installable": False,
"installable": True,
}
4 changes: 2 additions & 2 deletions datamodel/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _get_nested_schemas(schema):


class DatamodelDatabases(dict):
""" Holds a registry of datamodels for each database """
"""Holds a registry of datamodels for each database"""


class DatamodelRegistry(object):
Expand Down Expand Up @@ -213,7 +213,7 @@ def __init__(self, context=None, partial=None, env=None, **kwargs):

@property
def env(self):
""" Current datamodels registry"""
"""Current datamodels registry"""
return self._env

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion datamodel/i18n/datamodel.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
Expand Down
6 changes: 3 additions & 3 deletions datamodel/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Datamodel</h1>
!! This file is generated by oca-gen-addon-readme !!
!! 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/rest-framework/tree/14.0/datamodel"><img alt="OCA/rest-framework" src="https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rest-framework-14-0/rest-framework-14-0-datamodel"><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/271/14.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/rest-framework/tree/15.0/datamodel"><img alt="OCA/rest-framework" src="https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/rest-framework-14-0/rest-framework-14-0-datamodel"><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/271/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This addon allows you to define simple data models supporting serialization/deserialization
to/from json</p>
<p>Datamodels are <a class="reference external" href="https://github.com/sv-tools/marshmallow-objects">Marshmallow models</a> classes that can be inherited as Odoo
Expand Down Expand Up @@ -468,7 +468,7 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rest-framework/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/rest-framework/issues/new?body=module:%20datamodel%0Aversion:%2014.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/rest-framework/issues/new?body=module:%20datamodel%0Aversion:%2015.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>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -502,7 +502,7 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/lmignon"><img alt="lmignon" src="https://github.com/lmignon.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rest-framework/tree/14.0/datamodel">OCA/rest-framework</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/rest-framework/tree/15.0/datamodel">OCA/rest-framework</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>
</div>
</div>
Expand Down
70 changes: 16 additions & 54 deletions datamodel/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ def notready():
class TransactionDatamodelCase(common.TransactionCase, DatamodelMixin):
"""A TransactionCase that loads all the datamodels

It it used like an usual Odoo's TransactionCase, but it ensures
It is used like an usual Odoo's TransactionCase, but it ensures
that all the datamodels of the current addon and its dependencies
are loaded.

"""

@classmethod
def setUpClass(cls):
super(TransactionDatamodelCase, cls).setUpClass()
super().setUpClass()
cls.setUpDatamodel()

# pylint: disable=W8106
Expand All @@ -79,30 +79,8 @@ def setUp(self):
DatamodelMixin.setUp(self)


class SavepointDatamodelCase(common.SavepointCase, DatamodelMixin):
"""A SavepointCase that loads all the datamodels

It is used like an usual Odoo's SavepointCase, but it ensures
that all the datamodels of the current addon and its dependencies
are loaded.

"""

@classmethod
def setUpClass(cls):
super(SavepointDatamodelCase, cls).setUpClass()
cls.setUpDatamodel()

# pylint: disable=W8106
def setUp(self):
# resolve an inheritance issue (common.SavepointCase does not call
# super)
common.SavepointCase.setUp(self)
DatamodelMixin.setUp(self)


class DatamodelRegistryCase(
common.TreeCase, common.MetaCase("DummyCase", (object,), {})
common.BaseCase, common.MetaCase("DummyCase", (object,), {})
):
"""This test case can be used as a base for writings tests on datamodels

Expand All @@ -111,10 +89,9 @@ class DatamodelRegistryCase(
or not, or when you want to create additional datamodels in your tests.

If you only want to *use* the datamodels of the tested addon in your tests,
then consider using one of:
then consider using:

* :class:`TransactionDatamodelCase`
* :class:`SavepointDatamodelCase`

This test case creates a special
:class:`odoo.addons.datamodel.core.DatamodelRegistry` for the purpose of
Expand All @@ -136,8 +113,7 @@ class DatamodelRegistryCase(
"""

def setUp(self):
super(DatamodelRegistryCase, self).setUp()

super().setUp()
# keep the original classes registered by the metaclass
# so we'll restore them at the end of the tests, it avoid
# to pollute it with Stub / Test datamodels
Expand Down Expand Up @@ -179,7 +155,7 @@ def _close_and_roolback():
self.datamodel_registry.ready = True

def tearDown(self):
super(DatamodelRegistryCase, self).tearDown()
super().tearDown()
# restore the original metaclass' classes
MetaDatamodel._modules_datamodels = self._original_datamodels

Expand All @@ -192,32 +168,18 @@ def _build_datamodels(self, *classes):


class TransactionDatamodelRegistryCase(common.TransactionCase, DatamodelRegistryCase):
""" Adds Odoo Transaction in the base Datamodel TestCase """
"""Adds Odoo Transaction in the base Datamodel TestCase"""

# pylint: disable=W8106
def setUp(self):
@classmethod
def setUpClass(cls):
# resolve an inheritance issue (common.TransactionCase does not use
# super)
common.TransactionCase.setUp(self)
DatamodelRegistryCase.setUp(self)
self.collection = self.env["collection.base"]

def teardown(self):
common.TransactionCase.tearDown(self)
DatamodelRegistryCase.tearDown(self)


class SavepointDatamodelRegistryCase(common.SavepointCase, DatamodelRegistryCase):
""" Adds Odoo Transaction with Savepoint in the base Datamodel TestCase """

# pylint: disable=W8106
def setUp(self):
# resolve an inheritance issue (common.SavepointCase does not use
# super)
common.SavepointCase.setUp(self)
DatamodelRegistryCase.setUp(self)
self.collection = self.env["collection.base"]
common.TransactionCase.setUpClass(cls)
DatamodelRegistryCase.setUp(cls)
cls.collection = cls.env["collection.base"]

def teardown(self):
common.SavepointCase.tearDown(self)
DatamodelRegistryCase.tearDown(self)
@classmethod
def tearDownClass(cls):
common.TransactionCase.tearDownClass(cls)
DatamodelRegistryCase.tearDown(cls)
26 changes: 14 additions & 12 deletions datamodel/tests/test_build_datamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Datamodel2(Datamodel):
self.assertIsInstance(Datamodel2(), MarshmallowModel)

def test_no_name(self):
""" Ensure that a datamodel has a _name """
"""Ensure that a datamodel has a _name"""

class Datamodel1(Datamodel):
pass
Expand All @@ -50,7 +50,7 @@ class Datamodel1(Datamodel):
Datamodel1._build_datamodel(self.datamodel_registry)

def test_register(self):
""" Able to register datamodels in datamodels registry """
"""Able to register datamodels in datamodels registry"""

class Datamodel1(Datamodel):
_name = "datamodel1"
Expand All @@ -66,8 +66,9 @@ class Datamodel2(Datamodel):
["base", "datamodel1", "datamodel2"], list(self.datamodel_registry)
)

# pylint: disable=R7980
def test_inherit_bases(self):
""" Check __bases__ of Datamodel with _inherit """
"""Check __bases__ of Datamodel with _inherit"""

class Datamodel1(Datamodel):
_name = "datamodel1"
Expand All @@ -90,7 +91,7 @@ class Datamodel3(Datamodel):
)

def test_prototype_inherit_bases(self):
""" Check __bases__ of Datamodel with _inherit and different _name """
"""Check __bases__ of Datamodel with _inherit and different _name"""

class Datamodel1(Datamodel):
_name = "datamodel1"
Expand Down Expand Up @@ -188,7 +189,7 @@ class Datamodel4(Datamodel):
)

def test_custom_build(self):
""" Check that we can hook at the end of a Datamodel build """
"""Check that we can hook at the end of a Datamodel build"""

class Datamodel1(Datamodel):
_name = "datamodel1"
Expand All @@ -203,8 +204,9 @@ def _complete_datamodel_build(cls):
# we inspect that our custom build has been executed
self.assertTrue(self.env.datamodels["datamodel1"]._build_done)

# pylint: disable=W8110
def test_inherit_attrs(self):
""" Check attributes inheritance of Datamodels with _inherit """
"""Check attributes inheritance of Datamodels with _inherit"""

class Datamodel1(Datamodel):
_name = "datamodel1"
Expand Down Expand Up @@ -236,7 +238,7 @@ def say(self):
self.assertEqual("foo bar", datamodel2.say())

def test_duplicate_datamodel(self):
""" Check that we can't have 2 datamodels with the same name """
"""Check that we can't have 2 datamodels with the same name"""

class Datamodel1(Datamodel):
_name = "datamodel1"
Expand All @@ -250,7 +252,7 @@ class Datamodel2(Datamodel):
Datamodel2._build_datamodel(self.datamodel_registry)

def test_no_parent(self):
""" Ensure we can't _inherit a non-existent datamodel """
"""Ensure we can't _inherit a non-existent datamodel"""

class Datamodel1(Datamodel):
_name = "datamodel1"
Expand All @@ -261,7 +263,7 @@ class Datamodel1(Datamodel):
Datamodel1._build_datamodel(self.datamodel_registry)

def test_no_parent2(self):
""" Ensure we can't _inherit by prototype a non-existent datamodel """
"""Ensure we can't _inherit by prototype a non-existent datamodel"""

class Datamodel1(Datamodel):
_name = "datamodel1"
Expand All @@ -276,7 +278,7 @@ class Datamodel2(Datamodel):
Datamodel2._build_datamodel(self.datamodel_registry)

def test_add_inheritance(self):
""" Ensure we can add a new inheritance """
"""Ensure we can add a new inheritance"""

class Datamodel1(Datamodel):
_name = "datamodel1"
Expand Down Expand Up @@ -339,7 +341,7 @@ class Datamodel1(Datamodel):
self.env.datamodels["datamodel1"](field_str="1234")

def test_nested_model(self):
""" Test nested model serialization/deserialization"""
"""Test nested model serialization/deserialization"""

class Parent(Datamodel):
_name = "parent"
Expand All @@ -366,7 +368,7 @@ class Child(Datamodel):
self.assertEqual(new_instance.child.field_str, instance.child.field_str)

def test_list_nested_model(self):
""" Test list model of nested model serialization/deserialization"""
"""Test list model of nested model serialization/deserialization"""

class Parent(Datamodel):
_name = "parent"
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# generated from manifests external_dependencies
marshmallow
marshmallow-objects>=2.0.0
1 change: 1 addition & 0 deletions setup/datamodel/odoo/addons/datamodel
6 changes: 6 additions & 0 deletions setup/datamodel/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)