Skip to content

Commit c9bf821

Browse files
committed
Merge PR #222 into 15.0
Signed-off-by lmignon
2 parents a26f69a + 2781ba7 commit c9bf821

11 files changed

Lines changed: 52 additions & 79 deletions

File tree

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ exclude: |
77
^base_rest_auth_user_service/|
88
^base_rest_datamodel/|
99
^base_rest_demo/|
10-
^datamodel/|
1110
^graphql_base/|
1211
^graphql_demo/|
1312
^model_serializer/|

datamodel/README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ Datamodel
1414
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1515
:alt: License: LGPL-3
1616
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frest--framework-lightgray.png?logo=github
17-
:target: https://github.com/OCA/rest-framework/tree/14.0/datamodel
17+
:target: https://github.com/OCA/rest-framework/tree/15.0/datamodel
1818
:alt: OCA/rest-framework
1919
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
2020
:target: https://translation.odoo-community.org/projects/rest-framework-14-0/rest-framework-14-0-datamodel
2121
:alt: Translate me on Weblate
2222
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
23-
:target: https://runbot.odoo-community.org/runbot/271/14.0
23+
:target: https://runbot.odoo-community.org/runbot/271/15.0
2424
:alt: Try me on Runbot
2525

2626
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -129,7 +129,7 @@ Bug Tracker
129129
Bugs are tracked on `GitHub Issues <https://github.com/OCA/rest-framework/issues>`_.
130130
In case of trouble, please check there if your issue has already been reported.
131131
If you spotted it first, help us smashing it by providing a detailed and welcomed
132-
`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**>`_.
132+
`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**>`_.
133133

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

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

171171
|maintainer-lmignon|
172172

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

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

datamodel/__manifest__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"summary": """
77
This addon allows you to define simple data models supporting
88
serialization/deserialization""",
9-
"version": "14.0.3.0.4",
9+
"version": "15.0.1.0.0",
1010
"license": "LGPL-3",
1111
"development_status": "Beta",
1212
"author": "ACSONE SA/NV, " "Odoo Community Association (OCA)",
@@ -16,5 +16,5 @@
1616
"data": [],
1717
"demo": [],
1818
"external_dependencies": {"python": ["marshmallow", "marshmallow-objects>=2.0.0"]},
19-
"installable": False,
19+
"installable": True,
2020
}

datamodel/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _get_nested_schemas(schema):
5353

5454

5555
class DatamodelDatabases(dict):
56-
""" Holds a registry of datamodels for each database """
56+
"""Holds a registry of datamodels for each database"""
5757

5858

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

214214
@property
215215
def env(self):
216-
""" Current datamodels registry"""
216+
"""Current datamodels registry"""
217217
return self._env
218218

219219
@classmethod

datamodel/i18n/datamodel.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
msgid ""
66
msgstr ""
7-
"Project-Id-Version: Odoo Server 14.0\n"
7+
"Project-Id-Version: Odoo Server 15.0\n"
88
"Report-Msgid-Bugs-To: \n"
99
"Last-Translator: \n"
1010
"Language-Team: \n"

datamodel/static/description/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ <h1 class="title">Datamodel</h1>
367367
!! This file is generated by oca-gen-addon-readme !!
368368
!! changes will be overwritten. !!
369369
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
370-
<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>
370+
<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>
371371
<p>This addon allows you to define simple data models supporting serialization/deserialization
372372
to/from json</p>
373373
<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
@@ -468,7 +468,7 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
468468
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/rest-framework/issues">GitHub Issues</a>.
469469
In case of trouble, please check there if your issue has already been reported.
470470
If you spotted it first, help us smashing it by providing a detailed and welcomed
471-
<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>
471+
<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>
472472
<p>Do not contact contributors directly about support or help with technical issues.</p>
473473
</div>
474474
<div class="section" id="credits">
@@ -502,7 +502,7 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
502502
promote its widespread use.</p>
503503
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
504504
<p><a class="reference external" href="https://github.com/lmignon"><img alt="lmignon" src="https://github.com/lmignon.png?size=40px" /></a></p>
505-
<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>
505+
<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>
506506
<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>
507507
</div>
508508
</div>

datamodel/tests/common.py

Lines changed: 16 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ def notready():
6060
class TransactionDatamodelCase(common.TransactionCase, DatamodelMixin):
6161
"""A TransactionCase that loads all the datamodels
6262
63-
It it used like an usual Odoo's TransactionCase, but it ensures
63+
It is used like an usual Odoo's TransactionCase, but it ensures
6464
that all the datamodels of the current addon and its dependencies
6565
are loaded.
6666
6767
"""
6868

6969
@classmethod
7070
def setUpClass(cls):
71-
super(TransactionDatamodelCase, cls).setUpClass()
71+
super().setUpClass()
7272
cls.setUpDatamodel()
7373

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

8181

82-
class SavepointDatamodelCase(common.SavepointCase, DatamodelMixin):
83-
"""A SavepointCase that loads all the datamodels
84-
85-
It is used like an usual Odoo's SavepointCase, but it ensures
86-
that all the datamodels of the current addon and its dependencies
87-
are loaded.
88-
89-
"""
90-
91-
@classmethod
92-
def setUpClass(cls):
93-
super(SavepointDatamodelCase, cls).setUpClass()
94-
cls.setUpDatamodel()
95-
96-
# pylint: disable=W8106
97-
def setUp(self):
98-
# resolve an inheritance issue (common.SavepointCase does not call
99-
# super)
100-
common.SavepointCase.setUp(self)
101-
DatamodelMixin.setUp(self)
102-
103-
10482
class DatamodelRegistryCase(
105-
common.TreeCase, common.MetaCase("DummyCase", (object,), {})
83+
common.BaseCase, common.MetaCase("DummyCase", (object,), {})
10684
):
10785
"""This test case can be used as a base for writings tests on datamodels
10886
@@ -111,10 +89,9 @@ class DatamodelRegistryCase(
11189
or not, or when you want to create additional datamodels in your tests.
11290
11391
If you only want to *use* the datamodels of the tested addon in your tests,
114-
then consider using one of:
92+
then consider using:
11593
11694
* :class:`TransactionDatamodelCase`
117-
* :class:`SavepointDatamodelCase`
11895
11996
This test case creates a special
12097
:class:`odoo.addons.datamodel.core.DatamodelRegistry` for the purpose of
@@ -136,8 +113,7 @@ class DatamodelRegistryCase(
136113
"""
137114

138115
def setUp(self):
139-
super(DatamodelRegistryCase, self).setUp()
140-
116+
super().setUp()
141117
# keep the original classes registered by the metaclass
142118
# so we'll restore them at the end of the tests, it avoid
143119
# to pollute it with Stub / Test datamodels
@@ -179,7 +155,7 @@ def _close_and_roolback():
179155
self.datamodel_registry.ready = True
180156

181157
def tearDown(self):
182-
super(DatamodelRegistryCase, self).tearDown()
158+
super().tearDown()
183159
# restore the original metaclass' classes
184160
MetaDatamodel._modules_datamodels = self._original_datamodels
185161

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

193169

194170
class TransactionDatamodelRegistryCase(common.TransactionCase, DatamodelRegistryCase):
195-
""" Adds Odoo Transaction in the base Datamodel TestCase """
171+
"""Adds Odoo Transaction in the base Datamodel TestCase"""
196172

197173
# pylint: disable=W8106
198-
def setUp(self):
174+
@classmethod
175+
def setUpClass(cls):
199176
# resolve an inheritance issue (common.TransactionCase does not use
200177
# super)
201-
common.TransactionCase.setUp(self)
202-
DatamodelRegistryCase.setUp(self)
203-
self.collection = self.env["collection.base"]
204-
205-
def teardown(self):
206-
common.TransactionCase.tearDown(self)
207-
DatamodelRegistryCase.tearDown(self)
208-
209-
210-
class SavepointDatamodelRegistryCase(common.SavepointCase, DatamodelRegistryCase):
211-
""" Adds Odoo Transaction with Savepoint in the base Datamodel TestCase """
212-
213-
# pylint: disable=W8106
214-
def setUp(self):
215-
# resolve an inheritance issue (common.SavepointCase does not use
216-
# super)
217-
common.SavepointCase.setUp(self)
218-
DatamodelRegistryCase.setUp(self)
219-
self.collection = self.env["collection.base"]
178+
common.TransactionCase.setUpClass(cls)
179+
DatamodelRegistryCase.setUp(cls)
180+
cls.collection = cls.env["collection.base"]
220181

221-
def teardown(self):
222-
common.SavepointCase.tearDown(self)
223-
DatamodelRegistryCase.tearDown(self)
182+
@classmethod
183+
def tearDownClass(cls):
184+
common.TransactionCase.tearDownClass(cls)
185+
DatamodelRegistryCase.tearDown(cls)

datamodel/tests/test_build_datamodel.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Datamodel2(Datamodel):
4040
self.assertIsInstance(Datamodel2(), MarshmallowModel)
4141

4242
def test_no_name(self):
43-
""" Ensure that a datamodel has a _name """
43+
"""Ensure that a datamodel has a _name"""
4444

4545
class Datamodel1(Datamodel):
4646
pass
@@ -50,7 +50,7 @@ class Datamodel1(Datamodel):
5050
Datamodel1._build_datamodel(self.datamodel_registry)
5151

5252
def test_register(self):
53-
""" Able to register datamodels in datamodels registry """
53+
"""Able to register datamodels in datamodels registry"""
5454

5555
class Datamodel1(Datamodel):
5656
_name = "datamodel1"
@@ -66,8 +66,9 @@ class Datamodel2(Datamodel):
6666
["base", "datamodel1", "datamodel2"], list(self.datamodel_registry)
6767
)
6868

69+
# pylint: disable=R7980
6970
def test_inherit_bases(self):
70-
""" Check __bases__ of Datamodel with _inherit """
71+
"""Check __bases__ of Datamodel with _inherit"""
7172

7273
class Datamodel1(Datamodel):
7374
_name = "datamodel1"
@@ -90,7 +91,7 @@ class Datamodel3(Datamodel):
9091
)
9192

9293
def test_prototype_inherit_bases(self):
93-
""" Check __bases__ of Datamodel with _inherit and different _name """
94+
"""Check __bases__ of Datamodel with _inherit and different _name"""
9495

9596
class Datamodel1(Datamodel):
9697
_name = "datamodel1"
@@ -188,7 +189,7 @@ class Datamodel4(Datamodel):
188189
)
189190

190191
def test_custom_build(self):
191-
""" Check that we can hook at the end of a Datamodel build """
192+
"""Check that we can hook at the end of a Datamodel build"""
192193

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

207+
# pylint: disable=W8110
206208
def test_inherit_attrs(self):
207-
""" Check attributes inheritance of Datamodels with _inherit """
209+
"""Check attributes inheritance of Datamodels with _inherit"""
208210

209211
class Datamodel1(Datamodel):
210212
_name = "datamodel1"
@@ -236,7 +238,7 @@ def say(self):
236238
self.assertEqual("foo bar", datamodel2.say())
237239

238240
def test_duplicate_datamodel(self):
239-
""" Check that we can't have 2 datamodels with the same name """
241+
"""Check that we can't have 2 datamodels with the same name"""
240242

241243
class Datamodel1(Datamodel):
242244
_name = "datamodel1"
@@ -250,7 +252,7 @@ class Datamodel2(Datamodel):
250252
Datamodel2._build_datamodel(self.datamodel_registry)
251253

252254
def test_no_parent(self):
253-
""" Ensure we can't _inherit a non-existent datamodel """
255+
"""Ensure we can't _inherit a non-existent datamodel"""
254256

255257
class Datamodel1(Datamodel):
256258
_name = "datamodel1"
@@ -261,7 +263,7 @@ class Datamodel1(Datamodel):
261263
Datamodel1._build_datamodel(self.datamodel_registry)
262264

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

266268
class Datamodel1(Datamodel):
267269
_name = "datamodel1"
@@ -276,7 +278,7 @@ class Datamodel2(Datamodel):
276278
Datamodel2._build_datamodel(self.datamodel_registry)
277279

278280
def test_add_inheritance(self):
279-
""" Ensure we can add a new inheritance """
281+
"""Ensure we can add a new inheritance"""
280282

281283
class Datamodel1(Datamodel):
282284
_name = "datamodel1"
@@ -339,7 +341,7 @@ class Datamodel1(Datamodel):
339341
self.env.datamodels["datamodel1"](field_str="1234")
340342

341343
def test_nested_model(self):
342-
""" Test nested model serialization/deserialization"""
344+
"""Test nested model serialization/deserialization"""
343345

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

368370
def test_list_nested_model(self):
369-
""" Test list model of nested model serialization/deserialization"""
371+
"""Test list model of nested model serialization/deserialization"""
370372

371373
class Parent(Datamodel):
372374
_name = "parent"

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# generated from manifests external_dependencies
2+
marshmallow
3+
marshmallow-objects>=2.0.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../datamodel

0 commit comments

Comments
 (0)