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

[10.0->11.0]stock: error in migration script stock/migrations/11.0.1.1/end-migration.py: min() arg is an empty sequence #2324

Closed
khaeusler opened this issue Apr 26, 2020 · 6 comments
Milestone

Comments

@khaeusler
Copy link

I received the following error when migrating a DB from v10 to v11.

ERROR KH_9_mig OpenUpgrade: stock: error in migration script stock/migrations/11.0.1.1/end-migration.py: min() arg is an empty sequence
ERROR KH_9_mig OpenUpgrade: min() arg is an empty sequence
[…]
CRITICAL KH_9_mig odoo.service.server: Failed to initialize database `KH_9_mig`.
Traceback (most recent call last):
  File "/opt/odoo/lib/odoo/odoo/service/server.py", line 1043, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/opt/odoo/lib/odoo/odoo/modules/registry.py", line 85, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/opt/odoo/lib/odoo/odoo/modules/loading.py", line 463, in load_modules
    migrations.migrate_module(package, 'end')
  File "/opt/odoo/lib/odoo/odoo/modules/migration.py", line 199, in migrate_module
    migrate(self.cr, installed_version)
  File "/usr/local/lib/python3.5/dist-packages/openupgradelib/openupgrade.py", line 1778, in wrapped_function
    if use_env2 else cr, version)
  File "/opt/odoo/lib/odoo/addons/stock/migrations/11.0.1.1/end-migration.py", line 31, in migrate
    merge_quants(env)
  File "/opt/odoo/lib/odoo/addons/stock/migrations/11.0.1.1/end-migration.py", line 25, in merge_quants
    env, 'stock.quant', quants[1:].ids, quants[0].id, QUANT_MERGE_OPS,
  File "/usr/local/lib/python3.5/dist-packages/openupgradelib/openupgrade_merge_records.py", line 549, in merge_records
    _adjust_merged_values_orm(*args2)
  File "/usr/local/lib/python3.5/dist-packages/openupgradelib/openupgrade_merge_records.py", line 365, in _adjust_merged_values_orm
    vals[field.name] = min(_list)
ValueError: min() arg is an empty sequence

If the migration is started a second time, the error no longer occurs.

@pedrobaeza
Copy link
Member

Can you nag in which field is failing? The only way to get to this is that

https://github.com/OCA/openupgradelib/blob/5651e38dfc44f7ed97ca294af242c6bc00ec327a/openupgradelib/openupgrade_merge_records.py#L334

is returning an empty list, which is unlikely.

Second time is not happening because end-migration scripts are not run then. See #1879

@khaeusler
Copy link
Author

field: stock.quant.in_date
_list=[False, False, False, False, False, False]

@pedrobaeza
Copy link
Member

And doing min([False, False, False, False, False, False]) should give you False, not that error. Checked in local interpreter.

@khaeusler
Copy link
Author

(KH_9): $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> min(filter(lambda x: x is not False, ([False, False, False, False, False, False])))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: min() arg is an empty sequence

@pedrobaeza
Copy link
Member

OK, I see the problem because the op is indicated.

@legalsylvain
Copy link
Contributor

thanks @pedrobaeza !

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

3 participants