Uninstall of addons should not remove special fields (id, create_date, ...)

Bug #1262150 reported by Guewen Baconnier @ Camptocamp
48
This bug affects 11 people
Affects Status Importance Assigned to Milestone
Odoo Server (MOVED TO GITHUB)
Fix Released
Medium
OpenERP's Framework R&D

Bug Description

Steps to reproduce (warning! destroy the database!):

1) In a custom module, adds the following lines (these lines are in the base_partner_merge backport):

    class res_partner(osv.Model):
    _inherit = 'res.partner'

    _columns = {
        'id': fields.integer('Id', readonly=True),
        'create_date': fields.datetime('Create Date', readonly=True),
    }

2) Install the module
3) Uninstall the module

Result:
The columns 'id' and 'create_date' are dropped from the database.

Expected:
The columns 'id' and 'create_date' are still there.

Cause: the uninstall looks in ir_model_data and removes the columns no longer referenced by any record (a record in ir_model_data indicating that the column is still owned by another module). When we redeclare a special column, like "id", an ir_model_data entry is created for the custom module, example: base_partner_merge.field_res_partner_id, but the ORM does not create entries for theses columns normally -> when we uninstall the custom module, it removes the new xmlid and since there is no other xmlid, it drops the column.

Happens with https://code.launchpad.net/~camptocamp/partner-contact-management/add-base_partner_merge/+merge/189616 for instance.

Related branches

description: updated
Changed in openobject-server:
assignee: nobody → OpenERP's Framework R&D (openerp-dev-framework)
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Did you understood that uninstalling a module may trash the database as it will remove res_partner.id?
Is this bug really a *wishlist* ?

Revision history for this message
Matthieu Dietrich @ camptocamp (mdietrich-c2c) wrote :

How can a bug that can utterly break a complete DB, with no other solution than a full restore, be considered as "wishlist"?

Revision history for this message
Graeme Gellatly (gdgellatly) wrote :

Clearly a misunderstanding of bug importance, increasngly custom modules are requiring these fields to be displayed in ui -> set to medium so at least someone looks at it.

Changed in openobject-server:
importance: Wishlist → Medium
Revision history for this message
Christophe Combelles (ccomb) wrote :

This is a very dangerous bug indeed. The result for us was a DB DESTRUCTION and forced to restore the backup!!
Just by disabling the "customer portal" in the settings, it uninstalled base_partner_merge which depends on it and contains these lines.

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : Re: [Bug 1262150] Re: Uninstall of addons should not remove special fields (id, create_date, ...)

On 01/28/2014 12:08 AM, Christophe Combelles wrote:
> This is a very dangerous bug indeed. The result for us was a DB DESTRUCTION and forced to restore the backup!!
> Just by disabling the "customer portal" in the settings, it uninstalled base_partner_merge which depends on it and contains these lines.
>

Exact same story.

That's why I also reported:
https://bugs.launchpad.net/openobject-server/+bug/1262172

description: updated
description: updated
Revision history for this message
Christophe Combelles (ccomb) wrote :

Just to help people wanting to remove the module base_partner_merge, or any other module overloading a base field such as 'id' or 'create_date', the trick is to remove the xmlid corresponding to the field, before removing the module.
Go to settings → Technical → Sequences & identifiers → external identifiers → search 'merge' in Module → delete the two xmlids. Then uninstall the module.

Revision history for this message
Jean Weisbuch (m-jea0-p) wrote :

Removing the Warehouse module (which is not a custom module) removes the create_date column from res_partner.

Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

Hello,

I believe Christian has indeed misunderstood the importance of this problem, this is definitely a bug that was needed to be fixed.
We have merged a fix for this issue in server 7.0.

revno: 5245 [merge]
revision-id: <email address hidden>

Regards

Changed in openobject-server:
status: Confirmed → Fix Released
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Thanks!

Revision history for this message
Henri-Maxime Ducoulombier (chehax) wrote :

Hi,

Updated our /server directory (up to revno 5292) and this is indeed fixed.

Thank you !

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.