Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

odoo13 unittest: installed modules not available while testing

by
robert
- 28/07/2021 17:33:39
Hi there

I try to add some functionality to the payroll.

Now when I try to access the payroll stuff from within a test like so:

self.env['hr.payroll.structure']

I get a traceback:

Traceback (most recent call last):
   Debug Console, prompt 68, line 1
     import base64
   File 
"/home/robert/projects/odoo13/odoo13/downloads/odoo-13.0.post20201211/odoo/api.py", 
line 463, in __getitem__
     return self.registry[model_name]._browse(self, (), ())
   File 
"/home/robert/projects/odoo13/odoo13/downloads/odoo-13.0.post20201211/odoo/modules/registry.py", 
line 177, in __getitem__
     return self.models[model_name]
builtins.KeyError: 'hr.payroll.structure'

However, when I do exactly the same when not being in a unittest, everything 
works fine.

What could be the reason?

I am running on an ubuntu:

Distributor ID:    Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:    focal

using Python:

python
Python 3.8.2 (default, Feb 25 2020, 13:04:52)
[GCC 9.2.1 20200224] on linux

thanks for your input

Robert


Follow-Ups