Skip to Content
Menu
This question has been flagged

Hi all,

I'm modifying the report_invoice_document template by inheriting it and i'm facing weird localization issues. In the same xpath block, for a French customer, I get both amounts localized in English and in French. For example, the following xpath node produces the result bellow.

<template id="report_invoice_layouted" inherit_id="export_invoice.report_invoice_document">
            <!-- Grand total -->
            <xpath expr="//div[@id='tax_summary']" position="after">
                <t t-set="tax_amount" t-value="sum(tax.amount for tax in o.tax_line_ids)"/>
                <t t-if="tax_amount > 0">
                    <div class="row" id="invoice_total_dynamic">
                        <div class="col-xs-12">
                            <table class="table table-condensed">
                                <thead>
                                    <tr class="active">
                                        <th colspan="2">Grand total</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr class="border-black">
                                        <td>Subtotal</td>
                                        <td class="text-right">
                                            <span t-field="o.amount_untaxed"
                                                  t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
                                        </td>
                                    </tr>
                                    <t t-foreach="o._get_tax_amount_by_group()" t-as="amount_by_group">
                                        <tr>
                                            <td>
                                                <span t-esc="amount_by_group[0] if len(o.tax_line_ids) > 1 else (o.tax_line_ids.tax_id.description or o.tax_line_ids.tax_id.name)"/>
                                            </td>
                                            <td class="text-right">
                                                <span t-esc="amount_by_group[1]"
                                                      t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
                                            </td>
                                        </tr>
                                    </t>
                                </tbody>
                                <tfoot>
                                    <tr>
                                        <th>TOTAL INCLUDING TAXES</th>
                                        <th class="text-right">
                                            <span t-field="o.amount_total"
                                                  t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
                                        </th>
                                    </tr>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </t>
            </xpath>
</template>

Result: 

Grand total

Subtotal
 6 750,00 €
20.0
1,350.00 €
TOTAL INCLUDING TAXES
8 100,00 €

The same span in the same xpath block

<span t-field="XXXX" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>

displays numbers formatted either 8 888,88 € (French - thousand separator: space, decimal separator: comma or 8,888.88 € (English - thousand separator: comma, decimal separator: dot).

Any clue how to fix this?

Thanks.

Avatar
Discard
Author

It seems the issue is due to the way these model properties are computed :

amount_untaxed and amount_total are results of the sum() function whereas amount_by_group[1] is the result of subsequent additions.

./account/models/account_invoice.py:1145-1154 :

res[line.tax_id.tax_group_id] += line.amount

In the first case, the current user language is used.

In the second case, the t-lang="o.partner_id.lang" attribut as defined in <t t-call> tag is used.

Related Posts Replies Views Activity
2
Feb 24
7104
1
May 17
3366
1
Feb 24
31364
1
Mar 15
8081
1
Jul 24
402