OCA / OpenUpgrade

Open source upgrade path for Odoo/OpenERP
https://oca.github.io/OpenUpgrade/
GNU Affero General Public License v3.0
739 stars 696 forks source link

7 -> 8 error: constraint ir_ui_view_inherit_id_fkey #285

Closed welshjf closed 9 years ago

welshjf commented 9 years ago

Migrating a pretty simple installation: I'd just done basic company and user setup, installed the accounting module, and added a few test entries.

openerp.sql_db: bad query: delete from ir_ui_view where id IN (257)
Traceback (most recent call last):
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
IntegrityError: update or delete on table "ir_ui_view" violates foreign key constraint "ir_ui_view_inherit_id_fkey" on table "ir_ui_view"
DETAIL:  Key (id)=(257) is still referenced from table "ir_ui_view".

The constraint in question:

ALTER TABLE ir_ui_view
  ADD CONSTRAINT ir_ui_view_inherit_id_fkey FOREIGN KEY (inherit_id)
      REFERENCES ir_ui_view (id) MATCH SIMPLE
      ON UPDATE NO ACTION ON DELETE RESTRICT;

Here is the indicated record and the one that references it (hope this is vaguely legible; aligned mode output was worse):

id|model|type|arch|field_parent|priority|create_uid|create_date|write_date|write_uid|inherit_id|name|mode|active|model_data_id
257|account.invoice.report|tree|<?xml version="1.0"?>
<tree colors="blue:state == 'draft';gray:state in ('cancel','paid');black:state in ('proforma','proforma2')" create="false" string="Invoices Analysis">
                <field name="date" invisible="1"/>
                <field name="user_id" invisible="1"/>
                <field name="year" invisible="1"/>
                <field name="day" invisible="1"/>
                <field name="month" invisible="1"/>
                <field name="type" invisible="1"/>
                <field name="company_id" invisible="1"/>
                <field name="partner_id" invisible="1"/>
                <field name="product_id" invisible="1"/>
                <field name="uom_name" invisible="not context.get('set_visible',False)"/>
                <field name="categ_id" invisible="1"/>
                <field name="state" invisible="1"/>
                <field name="period_id" invisible="1"/>
                <field name="currency_id" invisible="1"/>
                <field name="journal_id" invisible="1"/>
                <field name="partner_bank_id" invisible="1"/>
                <field name="date_due" invisible="1"/>
                <field name="account_id" invisible="1"/>
                <field name="account_line_id" invisible="1"/>
                <field name="nbr" sum="# of Lines"/>
                <field name="product_qty" sum="Qty"/>
                <!-- <field name="reconciled"  sum="# Reconciled"/> -->
                <field name="price_total" sum="Total Without Tax"/>
            </tree>
        ||16|1|2015-05-03 06:23:17.719048|2015-05-03 06:23:17.719048|1||account.invoice.report.tree|primary|t|
458|account.invoice.report|tree|<?xml version="1.0"?>
<field name="partner_id" position="after">
                    <field name="commercial_partner_id" invisible="1"/>
                </field>
            ||16|1|2015-05-03 06:23:33.778936|2015-05-03 06:23:33.778936|1|257|account.invoice.report tree|primary|t|
(2 rows)

Not sure if this is a problem other than the error message. (Is there a way to tell in general if the upgrade was successful?)

And by the way, thanks for all the work on this project! It makes me feel a lot better about choosing Odoo.

hbrunn commented 9 years ago

the upgrade was successful if the database works in the target version ;-) Seriously: If everything went right, it will simply end with the message Modules loaded or, if you passed --stop-after-init (that's what migrate.py does), Initiating shutdown and Hit CTRL-C again or send a second signal to force the shutdown..

As for this view: Does it have an xml id? (select * from ir_model_data where model='ir.ui.view' and res_id=458) If yes, please post it. If not, it's a user defined view and you should delete it.

welshjf commented 9 years ago
id|create_uid|create_date|write_date|write_uid|noupdate|name|date_init|date_update|module|model|res_id
4795|1|2015-05-03 06:23:33.778936|2015-05-03 06:23:33.778936|1|f|account_report_company_invoice_report_tree_view|2015-05-03 06:23:33|2015-05-03 06:23:33|account_report_company|ir.ui.view|458
(1 row)

It does get to "initiating shutdown", and Odoo 8 starts up, but with "module not found" warnings for "process" and "account_report_company". (That second one definitely sounds related to this issue...)

hbrunn commented 9 years ago

ah, those warnings are normal. Use https://github.com/OCA/server-tools/tree/8.0/database_cleanup to clean up leftovers of deprecated modules

welshjf commented 9 years ago

I've installed database cleanup, gone to purge modules and found the two mentioned. The red X purge buttons on each line don't do anything. When I try "purge all modules", I get this (and they are not purged):

Traceback (most recent call last):
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/http.py", line 530, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/http.py", line 567, in dispatch
    result = self._call_function(**self.params)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/http.py", line 303, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/service/model.py", line 113, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/http.py", line 300, in checked_call
    return self.endpoint(*a, **kw)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/http.py", line 796, in __call__
    return self.method(*args, **kw)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/http.py", line 396, in response_wrap
    response = f(*args, **kw)
  File "/home/jwelsh/foss/odoo/odoo/addons/web/controllers/main.py", line 940, in call_button
    action = self._call_kw(model, method, args, {})
  File "/home/jwelsh/foss/odoo/odoo/addons/web/controllers/main.py", line 928, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/jwelsh/foss/odoo/server-tools/database_cleanup/model/purge_wizard.py", line 59, in purge_all
    context=context)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/jwelsh/foss/odoo/server-tools/database_cleanup/model/purge_modules.py", line 53, in purge
    _db, _pool = pooler.restart_pool(cr.dbname, update_module=True)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/pooler.py", line 46, in restart_pool
    registry = RegistryManager.new(db_name, force_demo, status, update_module)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/modules/registry.py", line 368, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/modules/loading.py", line 423, in load_modules
    registry['ir.module.module'].module_uninstall(cr, SUPERUSER_ID, modules_to_remove.values())
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/addons/base/module/module.py", line 462, in module_uninstall
    ir_model_data._module_data_uninstall(cr, uid, modules_to_remove, context)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/addons/base/ir/ir_model.py", line 1217, in _module_data_uninstall
    ir_model_constraint._module_data_uninstall(cr, uid, constraint_ids, context)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/api.py", line 241, in wrapper
    return old_api(self, *args, **kwargs)
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/addons/base/ir/ir_model.py", line 575, in _module_data_uninstall
    model_obj = self.pool[model]
  File "/home/jwelsh/.local/lib/python2.7/site-packages/openerp/modules/registry.py", line 102, in __getitem__
    return self.models[model_name]
KeyError: u'process.transition.action'
welshjf commented 9 years ago

Also I should add, before finding database_cleaner I had tried uninstalling the obsolete modules via the local modules interface. This not only threw a traceback (Programming error: column res_partner.display_name does not exist), but caused every request to do likewise, even after restarting the server, leaving the installation unusable until I restored a post-migration backup.

hbrunn commented 9 years ago

those are issues with database_cleanup, please post them at https://github.com/OCA/server-tools/issues

welshjf commented 9 years ago

Even the database corruption on trying to uninstall through the normal interface? Is that expected behavior for an un-cleaned database? Seems dangerous.

hbrunn commented 9 years ago

that's standard behavior of upstream. It doesn't take nonexisting models well, and the rest are followup errors

welshjf commented 9 years ago

OK, thank you. Reported at https://github.com/OCA/server-tools/issues/163.