Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0] Migration fails with deleted Weight Unit of Measure category #196

Closed
RoelAdriaans opened this issue Jan 4, 2015 · 2 comments
Closed

Comments

@RoelAdriaans
Copy link

Impacted versions: 7.0 to 8.0 upgrade

In my database I've deleted the Weight unit of measure category, default id = 3. As I only sell unit and hours.

When running the openupgrade script I get the error:

2015-01-04 11:31:21,291 12027 INFO openupgrade_migrated OpenUpgrade: product: loading migrations/8.0.1.1/modified_data.xml
2015-01-04 11:31:21,310 12027 ERROR openupgrade_migrated openerp.sql_db: bad query: INSERT INTO "product_uom" ("id", "uom_type", "active", "rounding", "create_uid", "write_uid", "c
reate_date", "write_date") VALUES(nextval('product_uom_id_seq'), 'reference', true, '0.001', 1, 1, (now() at time zone 'UTC'), (now() at time zone 'UTC')) RETURNING id
Traceback (most recent call last):
  File "/var/tmp/openupgrade/8.0/server/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
IntegrityError: null value in column "category_id" violates not-null constraint
[...]
  File "/var/tmp/openupgrade/8.0/server/openerp/modules/loading.py", line 295, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks, upg_registry=upg_registry)
  File "/var/tmp/openupgrade/8.0/server/openerp/modules/loading.py", line 215, in load_module_graph
    migrations.migrate_module(package, 'post')
  File "/var/tmp/openupgrade/8.0/server/openerp/modules/migration.py", line 179, in migrate_module
    mod.migrate(self.cr, pkg.installed_version)
  File "/var/tmp/openupgrade/8.0/server/openerp/openupgrade/openupgrade.py", line 716, in wrapped_function
    func(cr, version)
  File "/var/tmp/openupgrade/8.0/addons/product/migrations/8.0.1.1/post-migration.py", line 145, in migrate
    load_data(cr)
  File "/var/tmp/openupgrade/8.0/addons/product/migrations/8.0.1.1/post-migration.py", line 30, in load_data
[...]
ParseError: "null value in column "category_id" violates not-null constraint
DETAIL:  Failing row contains (20, 1, 2015-01-04 11:31:19.345763, 2015-01-04 11:31:19.345763, 1, reference, null, null, 0.001, null, t).
" while parsing /var/tmp/openupgrade/8.0/addons/product/migrations/8.0.1.1/modified_data.xml:8, near
<record id="product_uom_kgm" model="product.uom"><field name="rounding" eval="0.001"/>
        </record>

Deleting this line keeps the upgrade from failing, but is only a workaround..

It tries to update an uom that no longer exists. When deleting the uom KG. and keeping the category openupgrade adds a new KG uom. This fails then the Weight uim category is deleted.

Steps to reproduce:

  1. Clean version 7.0 installation (latest 7.0 head)
  2. Install product module, assign technical features and sales rights for the admin user
  3. Go to Sales/Unit of Measure Categories and delete category Weight.
  4. Update and fail.
@pedrobaeza
Copy link
Member

This is not a valid issue, because you must update your DB with latest code of the previous version before starting a migration, and the category will be again re-created in that operation. BTW, maybe we can fill an issue to Odoo for letting you delete the category having UoM with that type.

@RoelAdriaans
Copy link
Author

Makes sense. I see now that updating all is mentioned in the details documentation, but not on the automated migration script page. Since i wanted a quick and dirty migration, I stopped reading there :)

Deleting the category and uom fails when there are products with that uom, this looks like expected behavouir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants