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

[11→12]: psycopg2.ProgrammingError: can't adapt type 'res.company' [stock] #4419

Open
nikiwaibel opened this issue Apr 30, 2024 · 2 comments
Labels

Comments

@nikiwaibel
Copy link

i got this error: psycopg2.ProgrammingError: can't adapt type 'res.company' during the OpenUpgrade process [11→12].

(i am new to openupgrade)

Module

stock

Describe the bug

2024-04-30 07:51:29,525 4446 ERROR odoo12-from11 odoo.sql_db: bad query: UPDATE "stock_rule" SET "company_id"=%s,"write_uid"=%s,"write_date"=%s WHERE id IN %s
ERROR: can't adapt type 'res.company'
2024-04-30 07:51:29,526 4446 ERROR odoo12-from11 OpenUpgrade: stock: error in migration script stock/migrations/12.0.1.1/post-migration.py: can't adapt type 'res.company'
2024-04-30 07:51:29,526 4446 ERROR odoo12-from11 OpenUpgrade: can't adapt type 'res.company'
Traceback (most recent call last):
  File "/home/odoo/venv-3.6-odoo12/lib64/python3.6/site-packages/openupgradelib/openupgrade.py", line 2285, in wrapped_function
    version,
  File "/home/odoo/odoo11to12/OpenUpgrade-12/addons/stock/migrations/12.0.1.1/post-migration.py", line 181, in migrate
    merge_stock_location_path_stock_rule(env)
  File "/home/odoo/odoo11to12/OpenUpgrade-12/addons/stock/migrations/12.0.1.1/post-migration.py", line 98, in merge_stock_location_path_stock_rule
    row[0],
  File "/home/odoo/venv-3.6-odoo12/lib64/python3.6/site-packages/openupgradelib/openupgrade_merge_records.py", line 1036, in merge_records
    _adjust_merged_values_orm(*args2)
  File "/home/odoo/venv-3.6-odoo12/lib64/python3.6/site-packages/openupgradelib/openupgrade_merge_records.py", line 631, in _adjust_merged_values_orm
    target_record.write(new_vals)
2024-04-30 07:51:29,531 4446 ERROR odoo12-from11 odoo.modules.loading: Error executing post migration script for module stock
`-> product_expiry
`-> stock_picking_batch
: can't adapt type 'res.company'

obviously the error happens in OpenUpgrade-12/addons/stock/migrations/12.0.1.1/post-migration.py:merge_stock_location_path_stock_rule(), but i can't make out where exactly; nor i know, if this is caused by sthg that may have modified res.company in the first place or due to something wrong in my odoo-11 stock or due to an error / missing feature in OpenUpgrade-11 ("stock" is marked as "complete" …).

To Reproduce

Affected versions:

  • source system: odoo-11 (fedora26, python-3.6, postgres-9.6)
  • destination system: odoo-12 (fedora-28, python-3.6, postgres-10.7)

Steps to reproduce the behavior:

  1. i removed as much as i could from odoo-11 (some commercial modules like professional_templates - we want to get rif of them anyway)
  2. installed OCB-12 with OCA-12 modules and some others (website_webkul_addons, odoo_shipping_service_apps, …)
  3. createdb odoo12-from11
  4. psql -d odoo12-from11 -f dump.sql >/dev/null
  5. ./odoo11to12/OpenUpgrade-12/odoo-bin -d odoo12-from11 --without-demo=all --addons-path=odoo11to12/OpenUpgrade-12/addons,odoo11to12/commercialAddons,odoo11to12/OCA-12 -D . --update=all --stop-after-init >OpenUpgrade.log 2>&1

Expected behavior
update the database from 11 to 12 without error.

Additional context
in case the full log is required, just let me know.

@nikiwaibel nikiwaibel added the bug label Apr 30, 2024
@nikiwaibel
Copy link
Author

hmm, adding:

(venv-3.6-odoo12) [odoo@odoo12 OpenUpgrade-12]$ git diff
diff --git a/addons/stock/migrations/12.0.1.1/post-migration.py b/addons/stock/migrations/12.0.1.1/post-migration.py
index 5fa957ddccc..9d446cbe470 100644
--- a/addons/stock/migrations/12.0.1.1/post-migration.py
+++ b/addons/stock/migrations/12.0.1.1/post-migration.py
@@ -96,6 +96,7 @@ def merge_stock_location_path_stock_rule(env):
             env, 'stock.rule',
             [row[1]],
             row[0],
+            method="xxx"
         )
     pull_push_rule_ids = tuple(set([r[0] for r in rules_to_merge]))
     if pull_push_rule_ids:

let openupgrade finish.

@gdgellatly
Copy link

Can't adapt type is a common error. All it means is for example user.company_id is being passed instead of user.company_id.id - it should be trivial to find and fix. If it isn't in the upgrade scripts then it will be a module setting defaults incorrectly or similar.

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

No branches or pull requests

2 participants