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

[15.0] [16.0] l10n_es_ticketbai: raises "psycopg2.errors.UndefinedFunction: function to_date(date, unknown) does not exist" when upgrading from v14 #3900

Open
rrebollo opened this issue Jan 14, 2025 · 0 comments
Labels

Comments

@rrebollo
Copy link

rrebollo commented Jan 14, 2025

Module

l10n_es_ticketbai

Describe the bug

Using openupgrade in a doodba-copier-template project to go from v14.0 to v15.0 raises this error with the following traceback:

2025-01-14 17:14:33,492 1 INFO devel OpenUpgrade: l10n_es_ticketbai: post-migration script called with version 14.0.2.9.3
2025-01-14 17:14:33,492 1 ERROR devel odoo.sql_db: bad query:
        UPDATE tbai_invoice_refund_origin
        SET expedition_date = TO_DATE("openupgrade_legacy_15_0_expedition_date", 'DD-MM-YYYY')

ERROR: function to_date(date, unknown) does not exist
LINE 3:         SET expedition_date = TO_DATE("openupgrade_legacy_15...
                                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

2025-01-14 17:14:33,492 1 ERROR devel OpenUpgrade: Error after 0:00:00.000289 running
        UPDATE tbai_invoice_refund_origin
        SET expedition_date = TO_DATE("openupgrade_legacy_15_0_expedition_date", 'DD-MM-YYYY')

2025-01-14 17:14:33,492 1 ERROR devel OpenUpgrade: l10n_es_ticketbai: error in migration script /opt/odoo/auto/addons/l10n_es_ticketbai/migrations/15.0.1.4.6/post-migration.py: function to_date(date, unknown) does not exist
LINE 3:         SET expedition_date = TO_DATE("openupgrade_legacy_15...
                                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

2025-01-14 17:14:33,492 1 ERROR devel OpenUpgrade: function to_date(date, unknown) does not exist
LINE 3:         SET expedition_date = TO_DATE("openupgrade_legacy_15...
                                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/openupgradelib/openupgrade.py", line 2308, in wrapped_function
    func(
  File "/opt/odoo/auto/addons/l10n_es_ticketbai/migrations/15.0.1.4.6/post-migration.py", line 10, in migrate
    openupgrade.logged_query(
  File "/usr/local/lib/python3.8/site-packages/openupgradelib/openupgrade.py", line 1718, in logged_query
    cr.execute(query, args)
  File "<decorator-gen-5>", line 2, in execute
  File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 90, in check
    return f(self, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 311, in execute
    res = self._obj.execute(query, params)
psycopg2.errors.UndefinedFunction: function to_date(date, unknown) does not exist
LINE 3:         SET expedition_date = TO_DATE("openupgrade_legacy_15...
                                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Using openupgrade in a doodba-copier-template project to go from v15.0 to v16.0 raises this error with the following traceback:

ERROR devel odoo.sql_db: bad query:
        UPDATE tbai_invoice_refund_origin
        SET expedition_date = TO_DATE("openupgrade_legacy_16_0_expedition_date", 'DD-MM-YYYY')

ERROR: function to_date(date, unknown) does not exist
LINE 3:         SET expedition_date = TO_DATE("openupgrade_legacy_16...
                                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

2025-01-14 20:29:13,432 1 ERROR devel OpenUpgrade: Error after 0:00:00.000390 running
        UPDATE tbai_invoice_refund_origin
        SET expedition_date = TO_DATE("openupgrade_legacy_16_0_expedition_date", 'DD-MM-YYYY')

2025-01-14 20:29:13,432 1 ERROR devel OpenUpgrade: l10n_es_ticketbai: error in migration script /opt/odoo/auto/addons/l10n_es_ticketbai/migrations/16.0.1.0.1/post-migration.py: function to_date(date, unknown) does not exist
LINE 3:         SET expedition_date = TO_DATE("openupgrade_legacy_16...
                                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

2025-01-14 20:29:13,432 1 ERROR devel OpenUpgrade: function to_date(date, unknown) does not exist
LINE 3:         SET expedition_date = TO_DATE("openupgrade_legacy_16...
                                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/openupgradelib/openupgrade.py", line 2308, in wrapped_function
    func(
  File "/opt/odoo/auto/addons/l10n_es_ticketbai/migrations/16.0.1.0.1/post-migration.py", line 10, in migrate
    openupgrade.logged_query(
  File "/usr/local/lib/python3.10/site-packages/openupgradelib/openupgrade.py", line 1718, in logged_query
    cr.execute(query, args)
  File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 321, in execute
    res = self._obj.execute(query, params)
psycopg2.errors.UndefinedFunction: function to_date(date, unknown) does not exist
LINE 3:         SET expedition_date = TO_DATE("openupgrade_legacy_16...
                                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

2025-01-14 20:29:13,434 1 WARNING devel odoo.modules.loading: Transient module states were reset
2025-01-14 20:29:13,445 1 ERROR devel odoo.modules.registry: Failed to load registry
Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 485, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 373, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 237, in load_module_graph
    migrations.migrate_module(package, 'post')
  File "/opt/odoo/auto/addons/openupgrade_framework/odoo_patch/odoo/modules/migration.py", line 18, in migrate_module
    MigrationManager.migrate_module._original_method(self, pkg, stage)
  File "/opt/odoo/custom/src/odoo/odoo/modules/migration.py", line 189, in migrate_module
    migrate(self.cr, installed_version)
  File "/usr/local/lib/python3.10/site-packages/openupgradelib/openupgrade.py", line 2308, in wrapped_function
    func(
  File "/opt/odoo/auto/addons/l10n_es_ticketbai/migrations/16.0.1.0.1/post-migration.py", line 10, in migrate
    openupgrade.logged_query(
  File "/usr/local/lib/python3.10/site-packages/openupgradelib/openupgrade.py", line 1718, in logged_query
    cr.execute(query, args)
  File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 321, in execute
    res = self._obj.execute(query, params)
psycopg2.errors.UndefinedFunction: function to_date(date, unknown) does not exist
LINE 3:         SET expedition_date = TO_DATE("openupgrade_legacy_16...
                                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

2025-01-14 20:29:13,445 1 CRITICAL devel odoo.service.server: Failed to initialize database `devel`.
Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/service/server.py", line 1311, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "<decorator-gen-16>", line 2, in new
  File "/opt/odoo/custom/src/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 485, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 373, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 237, in load_module_graph
    migrations.migrate_module(package, 'post')
  File "/opt/odoo/auto/addons/openupgrade_framework/odoo_patch/odoo/modules/migration.py", line 18, in migrate_module
    MigrationManager.migrate_module._original_method(self, pkg, stage)
  File "/opt/odoo/custom/src/odoo/odoo/modules/migration.py", line 189, in migrate_module
    migrate(self.cr, installed_version)
  File "/usr/local/lib/python3.10/site-packages/openupgradelib/openupgrade.py", line 2308, in wrapped_function
    func(
  File "/opt/odoo/auto/addons/l10n_es_ticketbai/migrations/16.0.1.0.1/post-migration.py", line 10, in migrate
    openupgrade.logged_query(
  File "/usr/local/lib/python3.10/site-packages/openupgradelib/openupgrade.py", line 1718, in logged_query
    cr.execute(query, args)
  File "/opt/odoo/custom/src/odoo/odoo/sql_db.py", line 321, in execute
    res = self._obj.execute(query, params)
psycopg2.errors.UndefinedFunction: function to_date(date, unknown) does not exist
LINE 3:         SET expedition_date = TO_DATE("openupgrade_legacy_16...
                                      ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

2025-01-14 20:29:13,446 1 INFO devel odoo.service.server: Stopping gracefully

To Reproduce

Steps to reproduce the behavior:

  1. Upgrade from v14 to v15 using OpenUpgrade or from v15 to v16

Expected behavior
Addon post-migration scrip pass successfully

Context

doodba-copier-template
openupgrade
postgres v14

@rrebollo rrebollo added the bug label Jan 14, 2025
@rrebollo rrebollo changed the title [15.0] l10n_es_ticketbai: raises "psycopg2.errors.UndefinedFunction: function to_date(date, unknown) does not exist" when upgrading from v14 [15.0] [16.0] l10n_es_ticketbai: raises "psycopg2.errors.UndefinedFunction: function to_date(date, unknown) does not exist" when upgrading from v14 Jan 14, 2025
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

1 participant