-
-
Notifications
You must be signed in to change notification settings - Fork 707
Description
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