İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
10667 Görünümler

Hello,

In Odoo the default language in reports is the partner language.

What I need to do is to add only one field and its translation in the same  report

i.e let's say in order/quotation report, I want to present the product name with two languages english and french  in the same quotation. How can I achieve that

Avatar
Vazgeç
Üretici

Update:

Here's a sample of my code in xml file:

<thead>

<tr>

<th>Product</th>

<th></th>

<th></th>

<th>Description</th>

<th>Description in French</th>

</tr>

</thead>

<tbody>

<t t-foreach="layout_category['lines']" t-as="line">

<tr t-attf-class="product-description row-{{line_parity}}">

<td style="padding:20px;" t-foreach="line.product_id" t-as="pro">

<span t-field="pro.avatar.image" t-field-options='{"widget": "image","class": "oe_avatar"}' style="padding:20px;"/>

</td>

<td></td>

<td></td>

<td class="colored">

<p t-field="line.name"/>

</td>

<td class="colored">

<p t-field="line.name" t-field-options='{"lang": "fr_FR"}'/>

</td>

</tr>

</t>

</tbody>

En İyi Yanıt

Try in your report template to add or pass context:

object.with_context({'lang':'en_US'}).name

So, just add the same field twice but with different context

Avatar
Vazgeç
Üretici

Hi, can you give me an example please.

I submitted a new comment with a sample of my code in xml file

In this line <p t-field="line.name" t-field-options='{"lang": "fr_FR"}'/>

I was trying to pass the language in t-field-options but it didn't work

Try tp:

<p t-field="line.with_context({'lang': 'fr_FR'}).name"/>

Üretici

it didn't work

Strange. Where does it lead? Is there an error?

Üretici

No errors as well.. Is there any alternative way to do it.. or at least can you just help me to understand the way to achieve it

The way above should work. No idea, why it doesn't work. Are you sure name has translation on French? Another alternative is to pre-define methods before genereting a report to pass a correct value. But you should use the same "with_context"

instead of t-field try t-esc or t-raw

İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Nis 17
2465
1
Haz 17
3035
0
May 24
2582
1
Ağu 23
28997
2
Ara 23
12700