Migration script for stock_location

Bug #1355054 reported by Rolf Wojtech
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenUpgrade Addons
New
Undecided
Unassigned

Bug Description

Find attached a migration script for stock_location based on stock's migration scripts. The only difference found in the analysis is the change from address_id (res.partner.address) to partner_id which is reflected in these migration scripts.

For reference, here is the error the migration attempt will throw without this patch:

2014-08-11 08:14:14,077 2836 ERROR xxxxx openerp.sql_db: bad query: ALTER TABLE "product_pulled_flow" ADD FOREIGN KEY ("partner_address_id") REFERENCES "res_partner" ON DELETE set null
Traceback (most recent call last):
  File "/opt/openerp/openupgrade-server/openerp/sql_db.py", line 226, in execute
    res = self._obj.execute(query, params)
IntegrityError: insert or update on table "product_pulled_flow" violates foreign key constraint "product_pulled_flow_partner_address_id_fkey"
DETAIL: Key (partner_address_id)=(78) is not present in table "res_partner".

2014-08-11 08:14:14,077 2836 ERROR xxxxx openerp: Failed to initialize database `xxxxx`.
Traceback (most recent call last):
  File "/opt/openerp/openupgrade-server/openerp/cli/server.py", line 98, in preload_registry
    db, registry = openerp.pooler.get_db_and_pool(dbname,update_module=update_module)
  File "/opt/openerp/openupgrade-server/openerp/pooler.py", line 33, in get_db_and_pool
    registry = RegistryManager.get(db_name, force_demo, status, update_module)
  File "/opt/openerp/openupgrade-server/openerp/modules/registry.py", line 192, in get
    update_module)
  File "/opt/openerp/openupgrade-server/openerp/modules/registry.py", line 218, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/opt/openerp/openupgrade-server/openerp/modules/loading.py", line 378, in load_modules
    processed_upgrade = load_marked_modules(cr, graph, states_to_load, force, status, report, loaded_modules, update_module, registry)
  File "/opt/openerp/openupgrade-server/openerp/modules/loading.py", line 285, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks, registry=registry)
  File "/opt/openerp/openupgrade-server/openerp/modules/loading.py", line 186, in load_module_graph
    init_module_models(cr, package.name, models)
  File "/opt/openerp/openupgrade-server/openerp/modules/module.py", line 381, in init_module_models
    obj._auto_end(cr, {'module': module_name})
  File "/opt/openerp/openupgrade-server/openerp/osv/orm.py", line 3243, in _auto_end
    cr.execute('ALTER TABLE "%s" ADD FOREIGN KEY ("%s") REFERENCES "%s" ON DELETE %s' % (t, k, r, d))
  File "/opt/openerp/openupgrade-server/openerp/sql_db.py", line 161, in wrapper
    return f(self, *args, **kwargs)
  File "/opt/openerp/openupgrade-server/openerp/sql_db.py", line 226, in execute
    res = self._obj.execute(query, params)
IntegrityError: insert or update on table "product_pulled_flow" violates foreign key constraint "product_pulled_flow_partner_address_id_fkey"
DETAIL: Key (partner_address_id)=(78) is not present in table "res_partner".

Revision history for this message
Rolf Wojtech (rolf-wojtech) wrote :
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Thanks for your contributions, Rolf! Can you please create proper bzr branches + merge proposals so that we can hold the regular review process?

Revision history for this message
Rolf Wojtech (rolf-wojtech) wrote :

To be honest I am anything but familiar with bzr/launchpad and have limited time for changing that and doing it "the proper way". Is there a guide or a resource you can point me to that describes the process? I would highly appreciate if somebody else could do that for me but if you insist, I can do it when I have some spare time.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :
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.