Skip to Content
Menú
This question has been flagged
1 Respondre
190 Vistes

While upgrading a custom module from odoo v15 to v19, I got the following error:


psycopg2.errors.UndefinedFunction: operator does not exist: character varying ->> unknown
LINE 1: ...Y "res_company"."sequence"  , "res_company"."name"->>'en_US'...

                                                                                                              ^

HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.


somewhere inside

<record id="party_user_account_move_rule" model="ir.rule">

            <field name="name">Party User Rule: All Invoices</field>

            <field name="model_id" ref="account.model_account_move"/>

            <field name="domain_force">[('move_type', 'in', ('out_invoice', 'out_refund'))]</field>

            <field name="groups" eval="[(4, ref('nvis_party.group_party_user')), (4, ref('nvis_party.group_party_supervisor')), (4, ref('nvis_party.group_party_new_supervisor'))]"/>

            <field name="perm_read" eval="True"/>

            <field name="perm_write" eval="True"/>

            <field name="perm_create" eval="False"/>

            <field name="perm_unlink" eval="False"/>

        </record>



How could I solve this issue?

Avatar
Descartar
Autor
ALTER TABLE res_company
ALTER COLUMN name TYPE jsonb USING name::jsonb;

This returns the following error:

ERROR: invalid input syntax for type json

Token "My" is invalid. 

SQL state: 22P02 

Detail: Token "My" is invalid. 

Context: JSON data, line 1: My...


Note: my company name is "My Company"

What should I do?

Best Answer

Hi,

This error usually appears when a database migrated from an older Odoo version contains fields that changed type — for example, from JSON to plain text.

Odoo is trying to use a JSON operator (->>) on a varchar field, which PostgreSQL doesn’t allow, leading to:


operator does not exist: character varying ->> unknown


To fix this, make sure your database schema matches the Odoo version you’re running.

If it’s an upgraded DB, update the affected column type to jsonb using:


ALTER TABLE table_name

ALTER COLUMN field_name TYPE jsonb USING field_name::jsonb;


Or adjust any custom SQL code to remove the JSON operator.

In my case, creating a new database with the same modules solved it, confirming the issue was schema mismatch.


Hope it helps

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
d’oct. 25
2640
1
de set. 25
2658
3
de jul. 25
4071
1
de maig 25
2169
4
de maig 25
3502