Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
93 Visualizzazioni

Hello,


on Odoo 18,

I just inherit res.company and set attribute translate=True like

`street = fields.Char(translate=True)`

There button translation on the field but when I try to set it to my language it always switch back to English.


or any idea to handle this.

Avatar
Abbandona
Risposta migliore

Hi,


In Odoo 18, simply setting translate=True on fields like street in res.company does not work as expected because these fields are treated as master data, meaning Odoo always displays the stored base value regardless of translations. While you may see the translation button, switching languages will not reflect the translated value. You can work around this in a few ways. One option is to manually manage translations in ir.translation, though this is fragile because updates to the company record can break translations. A better approach is to leverage the linked res.partner record, where you can extend and add translatable fields for the company’s address. Another, less practical option is to create separate companies for each language, but this makes accounting and setup unnecessarily complex. The cleanest long-term solution is to add custom translatable fields (such as street_translated, city_translated) on res.company or res.partner and adapt your reports (invoices, sales orders, purchase orders) to display values based on the document or user’s language. This ensures proper multilingual support for addresses while keeping master data intact.




Hope it helps

Avatar
Abbandona
Risposta migliore

Hi Theerayut Attajak,


translate=True only makes sense for fields that are stored in ir.translation (like product descriptions, UI labels, etc.). The res.company model is company-specific, not language-specific.


If you need different addresses in different languages, configure multi company. This way, each company can store its own address without using translations.


For more details, please refer to this blog:

https://www.cybrosys.com/blog/how-to-define-translations-in-a-custom-module-add-a-new-language-in-odoo-18

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
ago 25
129
2
ago 25
324
0
ago 25
353
1
ago 25
812
1
ago 25
569