Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
320 Lượt xem

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?

Ảnh đại diện
Huỷ bỏ
Tác giả
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?

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 10 25
2720
1
thg 9 25
2733
3
thg 7 25
4117
1
thg 5 25
2207
4
thg 5 25
3568