[7.0][Trunk] Server will crash if import from missing addons is made

Bug #1267149 reported by Nicolas Bessi - Camptocamp
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
New
Undecided
Unassigned

Bug Description

Hello,

Let say I have module A and module B.

B depends on A in __openerp__.py but the two addons are in different branches.

In B addons I have this code somewhere in the code:

from openerp.addons.A.a_module import myhelper

If I have B in addons path but not A. Server will raise an import error even if I have not required the installation of the B addon.
This will lead to a server crash at startup with a unclear error message.

This will also force people to have more branches to retrieve with all the trouble that goes along.

I understand why all the files with model classes have to be loaded in order to prepare final model state.

But I'm a little perplex on the reason of loading all files of an addon when graphing the addons dependence tree.
Only __openerp__.py should be loaded first in a safe manner, and when the graph is calculated then effectively load the packages.

It will avoid such trouble and also avoid (malicious) code to be executed when you do not want to.

Regards

Nicolas

description: updated
Revision history for this message
Gustavo Adrian Marino (gamarino) wrote : Re: [Bug 1267149] [NEW] [7.0][Trunk] Server will crash if import from missing addons is made
Download full text (4.4 KiB)

It is not the only problem.
If a module has a static javascript file, it will be loaded in UI even IF
THE MODULE IS NOT INSTALLED!, just because is in addons path.
There is no need to do that.
Regards

Gustavo Adrian Marino

Mobile: +54 911 5498 2515

Email: <email address hidden>

Skype: gustavo.adrian.marino

2014/1/8 Nicolas Bessi - Camptocamp <email address hidden>

> Public bug reported:
>
> Hello,
>
> Let say I have module A and module B.
>
> B depends on A in __openerp__.py but the two addons are in different
> branches.
>
> In B addons I have this code somewhere in the code:
>
> from openerp.addons.A.a_module import myhelper
>
> If I have B in addons path but not A server will raise an import error
> even if I have not require the istallation of the A addon.
> This will lead to a server crash at startup with a unclear error message.
>
> This will also force people to have more branch to retrieve with all the
> trouble that goes along.
>
> I understand why all the files with model classes have to be loaded in
> order to prepare final model state.
>
> But I'm a little perplex on the reason of loading all files of an addon
> when graphing the addons dependence tree.
> Only __openerp__.py should be loaded first in a safe manner, and when the
> graph is calculated then effectively load the packages.
>
> It will avoid such trouble and also avoid (malicious) code to be
> executed when you do not want to.
>
> Regards
>
> Nicolas
>
> ** Affects: openobject-server
> Importance: Undecided
> Status: New
>
> ** Description changed:
>
> Hello,
>
> Let say I have module A and module B.
>
> B depends on A in __openerp__.py but the two addons are in different
> branches.
>
> In B addons I have this code somewhere in the code:
>
> from openerp.addons.A.a_module import myhelper
>
> - If I have B in addons path but not A server will raise an import error
> even if I have not require the istallation of the addons.
> - This will lead to a server crash at startup with a unclear error message
> + If I have B in addons path but not A server will raise an import error
> even if I have not require the istallation of the A addon.
> + This will lead to a server crash at startup with a unclear error message.
>
> This will also force people to have more branch to retrieve with all the
> trouble that goes along.
>
> I understand why all the files with model classes have to be loaded in
> - order to prepare final Model form.
> + order to prepare final model state.
>
> - But I'm a little perplex on the reason of loading all files of an addon
> when graphing the addons dependence tree.
> + But I'm a little perplex on the reason of loading all files of an addon
> when graphing the addons dependence tree.
> Only __openerp__.py should be loaded first in a safe manner, and when
> the graph is calculated then effectively load the packages.
>
> It will avoid such trouble and also avoid (malicious) code to be
> executed when you do not want to.
>
> Regards
>
> Nicolas
>
> --
> You received this bug notification because you are subscribed to OpenERP
> Server.
> https://bugs.launchpad.net/bugs/1267149
>
> Title:
> [7.0][Trunk] ...

Read more...

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

IMO, if the various addons packages have to be imported, then OK so be it, but exceptions should be handled by the server code doing this, and when a modules for which an exception is raised at import is encountered, a log line should be added and the module should be tagged as not installable.

Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

@gamarino: the point_of_sale module depends on this "feature", which is unfortunate in my opinion.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.