Skip to Content
Menu
This question has been flagged

I would like to create and register a new Odoo model inside a test. Here is some example code demonstrating what I would like to accomplish:


class CreateModelInstanceTest(TransactionCase):
def test_create_model_instance(self):
class TestModel(Model):
_name = "test.model"
name = Char()

self.env["test.model"].create([{"name": "Test"}])

However, the test fails with KeyError: 'test.model'. It seems that the model needs to be added to the registry first.


How can I add the new TestModel model to the registry from within a test?

Avatar
Discard
Related Posts Replies Views Activity
1
May 20
2328
0
Mar 23
1016
1
Jan 24
12879
2
Apr 21
5503
1
Jun 18
2931