Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

RE: New Odoo17 translated fields

by
johan
- 01/02/2024 14:30:18

Thank you Silvio, I didn’t know this way also -) I’ll try this to.

 

With kind regards,

 

Van Hirtum Johan

 

Van: Silvio Gregorini [mailto:notifications@odoo-community.org]
Verzonden: donderdag 1 februari 2024 14:08
Aan: Contributors
Onderwerp: Re: New Odoo17 translated fields

 

Since v16, there's also a method made available by the ORM to update translations without overriding the context:

 

 

On Thu, Feb 1, 2024 at 1:52 PM Johan Van Hirtum <notifications@odoo-community.org> wrote:

Beautiful ! Thank you very much David -)

 

With kind regards,

 

Van Hirtum Johan

 

Van: David Vidal [mailto:notifications@odoo-community.org]
Verzonden: donderdag 1 februari 2024 13:08
Aan: Contributors
Onderwerp: Re: New Odoo17 translated fields

 

The ORM does it for you. Simply use the `lang` context:

 

```python

record.with_context(lang='es_ES`).field_name = translated_string

```

 

You can get your active languages with `self.env['res.lang'].get_installed()` and loop over them if you want to do it at once.

 

El jue, 1 feb 2024 a las 12:52, Johan Van Hirtum (<notifications@odoo-community.org>) escribió:

Dears,

 

Knows someone good developer documentation around the new translated fields in Odoo17 ? That there are stored in de database as jsonB field is clear. But I see nowhere how to set de translated terms for a field in a python method ( an on change or depends structure for ex. ). There must normally be a some variables where the translation are stored till the create method creates the model ? But I see nothing there.

I want to use a python translation package ( deepL, deep-translator ) to give a first translation automatically when the translatable field is typed in the ID. Users can adapt, if they want to, but mostly, these translation are simply good -)

 

Thanks for helping me out.

 

With kind regards,

 

 

Van Hirtum Johan

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

Reference