Skip to content

[18.0][mail_gateway]The module fails to install because it attempts to import the Odoo test. #1812

@percevaq

Description

@percevaq

Describe the bug
The module fails to install because it attempts to import the Odoo test framework within a business logic model. In Odoo, importing from odoo.tests in non-test mode is strictly forbidden to prevent security risks and memory issues.

The error specifically occurs in mail_message.py due to the import of RecordCapturer.

To Reproduce
Affected versions: 18.0

Steps to reproduce the behavior:

Use a clean Odoo 18.0 environment.

Install the mail_gateway_telegram module.

The installation will stop with an ImportError or a specific Odoo error log: "Importing test framework, avoid importing from business modules and when not running in test mode".

Expected behavior The module should install correctly without attempting to load the odoo.tests suite during standard execution.

Additional context
Log Traceback:

Python
File "/addons/social/mail_gateway/models/mail_message.py", line 6, in
from odoo.tests import RecordCapturer
File "/server/odoo/tests/common.py", line 99, in
_logger.error("Importing test framework, avoid importing from business modules...")
System info:

OS: Linux (Ubuntu 22.04)

Python version: 3.10

Odoo version: 18.0 Community

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions