Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
10670 Представления

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

Аватар
Отменить
Автор

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>

Лучший ответ

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

Аватар
Отменить
Автор

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

Автор

it didn't work

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

Автор

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

Related Posts Ответы Просмотры Активность
0
апр. 17
2474
1
июн. 17
3044
0
мая 24
2586
1
авг. 23
29001
2
дек. 23
12706