Unregistering a ConnectorUnit from a backend unregisters even when the addon is not installed

Bug #1196195 reported by Guewen Baconnier @ Camptocamp
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenERP Connector
Fix Released
High
Guewen Baconnier @ Camptocamp

Bug Description

Example:

    # 7.0-magentoerpconnect : /magentoerpconnect_pricing/product.py
    magento.unregister_class(product.ProductImportMapper)

    [...]
    @magento
    class ProductImportMapper(product.ProductImportMapper):
        _model_name = 'magento.product.product'

        @only_create
        @mapping
        def price(self, record):
            """ The price is imported at the creation of
            the product, then it is only modified and exported
            from OpenERP """
            return super(ProductImportMapper, self).price(record)

Expected:

When the adddon magentoerpconnect_pricing is installed, the magentoerpconnect's ProductImportMapper is unregistered and the magentoerpconnect_pricing's ProductImportMapper replace it.

Current behavior:

Even if magentoerpconnect_pricing is not installed, magentoerpconnect's ProductImportMapper is unregistered and replaced by the magentoerpconnect_pricing's ProductImportMapper. This is due to the fact that OpenERP import the Python module of all the addons, whether they are installed or not.

Correction proposition:

Remove the ``unregister`` capabilities on the backends.
Add a ``replacing`` when a ConnectorUnit is registered on a backend.

    [...]
    @magento(replacing=product.ProductImportMapper)
    class ProductImportMapper(product.ProductImportMapper):

The ConnectorUnit is determined at runtime, with an algorithm as follows:

    for each ConnectorUnit registered on the backend
        Exclude it if the addons where it is declared is not installed -> if the ConnectorUnit is replaced by another (could be several if many addons) -> append to the candidate list (recursively)
        returns the last candidate or an error if many / 0 are found

Changed in openerp-connector:
importance: Undecided → Critical
status: New → Confirmed
importance: Critical → High
assignee: nobody → Guewen Baconnier @ Camptocamp (gbaconnier-c2c)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Not sure if this really happens, I couldn't reproduce it.
However, strongly related to: lp:1187697

Changed in openerp-connector:
status: Confirmed → Opinion
status: Opinion → Incomplete
Changed in openerp-connector:
status: Incomplete → Fix Released
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :
information type: Embargoed → Public
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.