Skip to Content

Contributors

solved:Re: odoo13 unittest: installed modules not available while testing

On 29.07.21 10:41, Petar Najman wrote:
Looks like dependency issue.
Check if module in which you created this TestCase has dependency to module hr_payroll

that was the cause

thanks

robert


by robert - 12:21 - 29 Jul 2021

Reference

  • odoo13 unittest: installed modules not available while testing
    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
    
    
    

    by robert - 05:36 - 28 Jul 2021