콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

I am trying to make the name field of the res.partner model translatable by overriding the name field and adding translate=True attr. I've done this in odoo 15 and it worked like a charm but in odoo 17 I encountered this 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.

아바타
취소
베스트 답변

The error you're encountering occurs because the name field of res.partner is related to the name field of res.company, and in Odoo 17, the translation mechanism requires the related fields to explicitly support translations as well.

In Odoo 15, this wasn't as strict, but starting from Odoo 17, you need to ensure that any related fields that reference translatable fields also have the translate=True attribute.

In your case, the res.company model has a field like this:

name = fields.Char(related='partner_id.name', string='Company Name', required=True, store=True, readonly=False)

To fix the error, you need to override this field and add the translate=True attribute to it, like so:

name = fields.Char(related='partner_id.name', string='Company Name', required=True, store=True, readonly=False, translate=True)

By doing this, the translation mechanism will apply not only to the name field of res.partner but also to the name field in res.company, which is crucial for avoiding the PostgreSQL error related to the JSON extraction operator (->>). This adjustment ensures that both fields are handled correctly when translations are applied.

아바타
취소
작성자 베스트 답변

I found the solution.

There’s a related field for res.partner's name in res.company:

name = fields.Char(related='partner_id.name', string='Company Name', required=True, store=True, readonly=False)

This field needs to be overridden to include the translate=True attribute, like this:

name = fields.Char(related='partner_id.name', string='Company Name', required=True, store=True, readonly=False, translate=True)
아바타
취소
관련 게시물 답글 화면 활동
1
9월 24
1102
4
8월 24
1505
0
12월 24
1048
0
7월 24
1696
2
7월 24
2319