Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
10684 Widoki

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

Awatar
Odrzuć
Autor

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>

Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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"/>

Autor

it didn't work

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

Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
0
kwi 17
2482
1
cze 17
3047
0
maj 24
2594
1
sie 23
29012
2
gru 23
12710