تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
10676 أدوات العرض

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

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
أبريل 17
2478
1
يونيو 17
3045
0
مايو 24
2588
1
أغسطس 23
29004
2
ديسمبر 23
12707