Ir al contenido
Menú
Se marcó esta pregunta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
may 20
2675
0
mar 23
1346
1
ene 24
13546
2
abr 21
6095
1
jun 18
3285