Skip to Content
Menu
This question has been flagged
2 Replies
155 Views

Hello everyone,

I have a custom Odoo module that adds a new field to the account.move model using _inherit = 'account.move'. Inside my module’s Python file, I define the field (e.g., fields.Char) and a compute method. If I place this module folder into the Odoo addons directory (or specify the path via the command line) and then install/upgrade from the Apps menu, the field is recognized on account.move with no problems.

However, if I take that same module folder, zip it up, and use the “Import Module” feature in Odoo’s web interface, it says “Successfully imported module,” but the Python logic doesn’t seem to load. Whenever I try to access the custom field in a QWeb report (or anywhere else), I get an error like:

AttributeError: 'account.move' object has no attribute '<my_field_name>'

It appears that the .py code for my module never actually executes in this scenario, even though the module is marked as installed. I’ve confirmed that my zip includes the standard structure (__init__.py, __manifest__.py, models/, etc.).

My questions are:

  1. Is the “Import Module from ZIP” feature in certain Odoo versions limited to XML/data files, ignoring custom Python code?
  2. If so, is there any workaround to get Python inheritance and fields to register without manually placing the folder in addons_path?
  3. Are there certain hosting environments or Odoo configurations that fully support importing Python modules from a zip?

Thanks in advance for any insights or suggestions! Any experiences dealing with this limitation or recommended best practices would be greatly appreciated.

Avatar
Discard
Best Answer

There are many possible reasons why this error occur, 

  1. Check the fields are well-defined in your custom models. my_field_name = fields.Char("My field name") should be present

   2. models files are found in the __init__.py​, for your case the line from . import account_move​ should be present.

   3. Make sure you use in your views only defined fields present in your models

Avatar
Discard
Best Answer

Importable modules do not support any Python files other than __init__.py and __manifest__.py

See https://www.odoo.com/documentation/18.0/developer/tutorials/importable_modules.html

Avatar
Discard