acsone / click-odoo

Run python scripts in a Odoo environment
GNU Lesser General Public License v3.0
115 stars 44 forks source link

[FIX] Force loading of server wide modules first #35

Closed lmignon closed 4 months ago

lmignon commented 4 years ago

Without this change even if an addon is declared as server wide module, the import is not done before others addons. With this change we solve a problem with addons depending of base_sparse_field. base_sparse_field, patch the odoo.fields module to add the Serialized field. When an addon depends on base_sparse_field, the common way to declare a Serialized field is to write:

from odoo import fields
...
    my_serialized = fields.Serialized()

Unfortunately we observe in some cases that even if the addon is declared as a dependency of the addon using this kind of field, the code of the base_sparse_field is not yet imported when the addon is added into the python path and an AttributeError is raised: AttributeError: module 'odoo.fields' has no attribute 'Serialized'

A way to fix this issue at server startup is to delare base_spare_field as server_wide_addon. Unfortunately, this parameter was ignored by click-doo before this change.

Observed with Odoo 13.0

lmignon commented 4 years ago

@sbidoul The issue is maybe into the way odoo imports the addons into the python path... At least it seems that we are no more ensured that an addon an other addon depend on is already imported into the python path when the last one is imported.

lmignon commented 4 years ago

This seems to be on Odoo bug. Indeed, sometimes even if I declare base_sparse_field into the server_wide_module, the normal server startup fails...

sbidoul commented 4 months ago

So we can close this one?

lmignon commented 4 months ago

yes we can