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