OpenUpgrade mailing list archives
openupgrade@odoo-community.org
Browse archives
Re: [11 - 12]Migration of Odoo Asset Management to OCA Asset Management fails completely
by
Twanda AG, Ermin Trevisan
Hi all
This is a new round, another migration project and I'm stuck and completely lost again with account_asset_management.
Situation:
- Latest openupgradelib Version 3.0.0
- Latest OpenUpgrade Version 12.0
- Latest Module Version account_asset_management
Odoo Account Management was installed on Odoo 11.0. I followed Pedro's advise and made sure, that the Table account_asset does not exist (did manual database dump/restore and filestore move).
I did run OpenUpgrade as usual and it crashed while migrating account_asset_management. No new tables, such as account_asset or account_profiles are in the database. But while running it again with loglevel DEBUG, I could see that the tables were created, but got lost somehow:
2020-07-23 09:58:09,574 23151 DEBUG databaseX odoo.sql_db: query: CREATE TABLE "account_asset" (id SERIAL NOT NULL, PRIMARY KEY(id))
CREATE TABLE "account_asset_group_rel" ("asset_id" INTEGER NOT NULL,
2020-07-23 09:58:09,629 23151 DEBUG databaseX odoo.sql_db: query: CREATE TABLE "account_asset_group" (id SERIAL NOT NULL, PRIMARY KEY(id))
2020-07-23 09:58:09,664 23151 DEBUG databaseX odoo.sql_db: query: CREATE TABLE "account_asset_profile" (id SERIAL NOT NULL, PRIMARY KEY(id))
CREATE TABLE "account_asset_profile_group_rel" ("profile_id" INTEGER NOT NULL,
2020-07-23 09:58:09,714 23151 DEBUG databaseX odoo.sql_db: query: CREATE TABLE "account_asset_line" (id SERIAL NOT NULL, PRIMARY KEY(id))
2020-07-23 09:58:09,744 23151 DEBUG databaseX odoo.sql_db: query: CREATE TABLE "account_asset_recompute_trigger" (id SERIAL NOT NULL, PRIMARY KEY(id))
2020-07-23 09:58:09,894 23151 DEBUG databaseX odoo.sql_db: query: CREATE TABLE "account_asset_compute" (id SERIAL NOT NULL, PRIMARY KEY(id))
2020-07-23 09:58:09,911 23151 DEBUG databaseX odoo.sql_db: query: CREATE TABLE "account_asset_remove" (id SERIAL NOT NULL, PRIMARY KEY(id))
This is the traceback when OpenUpgrade crashed:
2020-07-23 09:39:05,855 22823 INFO databaseX odoo.modules.migration: module account_asset_management: Running migration [>12.0.1.0.0] pre-migration
2020-07-23 09:39:05,927 22823 INFO databaseX odoo.modules.migration: module account_asset_management: Running migration [>12.0.2.0.0] pre-migration
2020-07-23 09:39:06,250 22823 INFO databaseX odoo.modules.registry: module account_asset_management: creating or updating database tables
2020-07-23 09:39:06,327 22823 INFO databaseX odoo.models: Computing parent_path for table account_asset_group...
2020-07-23 09:39:06,638 22823 INFO databaseX odoo.models: Storing computed values of account.asset.depreciation_base
2020-07-23 09:39:06,639 22823 INFO databaseX odoo.models: Storing computed values of account.asset.value_residual
2020-07-23 09:39:06,640 22823 INFO databaseX odoo.models: Storing computed values of account.asset.value_depreciated
2020-07-23 09:39:06,655 22823 INFO databaseX odoo.models: Storing computed values of account.asset.company_currency_id
2020-07-23 09:39:06,834 22823 INFO databaseX odoo.models: Storing computed values of account.asset.line.remaining_value
2020-07-23 09:39:06,835 22823 INFO databaseX odoo.models: Storing computed values of account.asset.line.depreciated_value
2020-07-23 09:39:06,837 22823 INFO databaseX odoo.models: Storing computed values of account.asset.line.move_check
2020-07-23 09:39:07,432 22823 ERROR databaseX odoo.sql_db: bad query: ALTER TABLE "account_move_line" ADD FOREIGN KEY ("asset_id") REFERENCES "account_asset"("id") ON DELETE restrict
ERROR: insert or update on table "account_move_line" violates foreign key constraint "account_move_line_asset_id_fkey"
DETAIL: Key (asset_id)=(11) is not present in table "account_asset".
2020-07-23 09:39:07,435 22823 WARNING databaseX odoo.modules.loading: Transient module states were reset
2020-07-23 09:39:07,437 22823 ERROR databaseX odoo.modules.registry: Failed to load registry
Traceback (most recent call last):
File "/odoo/openupgrade/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/odoo/openupgrade/odoo/modules/loading.py", line 480, in load_modules
force, status, report, loaded_modules, update_module, models_to_check, upg_registry)
File "/odoo/openupgrade/odoo/modules/loading.py", line 364, in load_marked_modules
upg_registry=upg_registry,
File "/odoo/openupgrade/odoo/modules/loading.py", line 222, in load_module_graph
registry.init_models(cr, model_names, {'module': package.name})
File "/odoo/openupgrade/odoo/modules/registry.py", line 304, in init_models
func()
File "/odoo/openupgrade/odoo/fields.py", line 2186, in update_db_foreign_key
new = process(model._cr, model._table, self.name, comodel._table, 'id', self.ondelete or 'set null')
File "/odoo/openupgrade/odoo/tools/sql.py", line 185, in fix_foreign_key
return add_foreign_key(cr, tablename1, columnname1, tablename2, columnname2, ondelete)
File "/odoo/openupgrade/odoo/tools/sql.py", line 158, in add_foreign_key
cr.execute(query.format(tablename1, columnname1, tablename2, columnname2, ondelete))
File "/odoo/openupgrade/odoo/sql_db.py", line 148, in wrapper
return f(self, *args, **kwargs)
File "/odoo/openupgrade/odoo/sql_db.py", line 225, in execute
res = self._obj.execute(query, params)
psycopg2.IntegrityError: insert or update on table "account_move_line" violates foreign key constraint "account_move_line_asset_id_fkey"
DETAIL: Key (asset_id)=(11) is not present in table "account_asset".
2020-07-23 09:39:07,438 22823 CRITICAL databaseX odoo.service.server: Failed to initialize database `databaseX`.
Traceback (most recent call last):
File "/odoo/openupgrade/odoo/service/server.py", line 1151, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
File "/odoo/openupgrade/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/odoo/openupgrade/odoo/modules/loading.py", line 480, in load_modules
force, status, report, loaded_modules, update_module, models_to_check, upg_registry)
File "/odoo/openupgrade/odoo/modules/loading.py", line 364, in load_marked_modules
upg_registry=upg_registry,
File "/odoo/openupgrade/odoo/modules/loading.py", line 222, in load_module_graph
registry.init_models(cr, model_names, {'module': package.name})
File "/odoo/openupgrade/odoo/modules/registry.py", line 304, in init_models
func()
File "/odoo/openupgrade/odoo/fields.py", line 2186, in update_db_foreign_key
new = process(model._cr, model._table, self.name, comodel._table, 'id', self.ondelete or 'set null')
File "/odoo/openupgrade/odoo/tools/sql.py", line 185, in fix_foreign_key
return add_foreign_key(cr, tablename1, columnname1, tablename2, columnname2, ondelete)
File "/odoo/openupgrade/odoo/tools/sql.py", line 158, in add_foreign_key
cr.execute(query.format(tablename1, columnname1, tablename2, columnname2, ondelete))
File "/odoo/openupgrade/odoo/sql_db.py", line 148, in wrapper
return f(self, *args, **kwargs)
File "/odoo/openupgrade/odoo/sql_db.py", line 225, in execute
res = self._obj.execute(query, params)
psycopg2.IntegrityError: insert or update on table "account_move_line" violates foreign key constraint "account_move_line_asset_id_fkey"
DETAIL: Key (asset_id)=(11) is not present in table "account_asset".
The error seems obvious to me based on the assumption that the table account_asset does not exist (asset_id 11 is the first asset record in the account move line table, when I delete it, then the same happens again with the next asset move line).
I'd be so happy for any hint or help in order to finally make an asset migration work without loosing countless hours to do it manually.
Thank you so much for any help!
Best, trevi
On Mon, 2020-06-01 at 11:14 +0200, Ermin Trevisan wrote:
Hi allAs referred by Pedro Baeza from the end of this thread: https://github.com/OCA/OpenUpgrade/issues/2159 I want to ask the community for help in this case, as I'm not a developer.At https://github.com/OCA/account-financial-tools/blob/418a0ddfaeefe0efaf6d18b6d8b175a0cd1f82d8/account_asset_management/migrations/12.0.1.0.0/pre-migration.py#L82 I would like to have a loud warning in the Odoo log that says that the migration will not work because the table "account_asset" already exists in the database. It is recommended to remove the table from the database and to restart the migration.In addition I'm wondering why this could happen at all, as it is not possible to install both asset management modules at the same time. The customer database I wanted to migrate did not have the table "account_asset" in the database. Therefore somehow this table got created during the OpenUpgrade process before the pre-migration script was executed.This was my migration process:- I have set up a migration server for 12.0 with the newest openupgradelib and a source install by sudo git clone --depth 1 --branch 12.0 https://github.com/OCA/OpenUpgrade $OE_HOME_EXT/- I have started Odoo from command line without any extra parameters just to get to the database manager GUI to restore the 11.0 database to migrate.- After the restore, I have stopped Odoo and have restarted it with the parameter -u all in order to start the migration.Is this correct and/or recommended or how do you do it?Thanks for any feedback, trevi--twanda AGErmin TrevisanArtherstrasse 19CH-6318 WalchwilT: +41 41 758 1515M: +41 79 208 7373
--twanda AGErmin TrevisanArtherstrasse 19CH-6318 Walchwil
T: +41 41 758 1515M: +41 79 208 7373E: trevi@twanda.comwww.twanda.ch
Reference
-
[11 - 12]Migration of Odoo Asset Management to OCA Asset Management fails completely
byTwanda AG, Ermin Trevisan-
Re: [11 - 12]Migration of Odoo Asset Management to OCA Asset Management fails completely
byTwanda AG, Ermin Trevisan -
Re: [11 - 12]Migration of Odoo Asset Management to OCA Asset Management fails completely
byTwanda AG, Ermin Trevisan -
Re: [11 - 12]Migration of Odoo Asset Management to OCA Asset Management fails completely
byTecnativa. S. L., Pedro M. Baeza
-