Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
114 Vistas

How can I display order and lines total in company currency when making order with foreign currency?

Note: I'm using Odoo Enterprise 

Avatar
Descartar
Mejor respuesta

Hi,


In Odoo Enterprise, when creating orders in a foreign currency, totals are automatically computed in the company currency for accounting purposes, but they may not be visible on the order form by default. To display them, you can enable multi-currencies in Accounting → Configuration → Settings and ensure the company currency is set correctly. Some settings, like “Show Amount in Company Currency,” can make the company currency total visible on the order.


For more detailed visibility, including line-level totals, a small customization can be added. This involves creating computed fields on both the order lines and the order itself, converting the foreign currency amounts to the company currency using Odoo’s _convert method. This approach allows users to see both the foreign currency and company currency totals directly on the order form and lines.


Overall, Odoo Enterprise supports displaying totals in company currency either via built-in settings or minor customizations to provide more detailed visibility for orders in foreign currencies.


1-Add fields on the order line:from odoo import fields, models, api


class SaleOrderLine(models.Model):

    _inherit = 'sale.order.line'


    price_subtotal_company = fields.Monetary(

        string='Subtotal (Company Currency)',

        currency_field='order_id.company_currency_id',

        compute='_compute_subtotal_company',

        store=True,

    )


    @api.depends('price_subtotal', 'order_id.currency_id', 'order_id.company_currency_id')

    def _compute_subtotal_company(self):

        for line in self:

            line.price_subtotal_company = line.order_id.currency_id._convert(

                line.price_subtotal,

                line.order_id.company_currency_id,

                line.company_id,

                line.order_id.date_order or fields.Date.today()

            )


2-Add a field on the order:


class SaleOrder(models.Model):

    _inherit = 'sale.order'


    amount_total_company = fields.Monetary(

        string='Total (Company Currency)',

        currency_field='company_currency_id',

        compute='_compute_amount_total_company',

        store=True,

    )


    @api.depends('amount_total', 'currency_id', 'company_currency_id')

    def _compute_amount_total_company(self):

        for order in self:

            order.amount_total_company = order.currency_id._convert(

                order.amount_total,

                order.company_currency_id,

                order.company_id,

                order.date_order or fields.Date.today()

            )


Hope it  helps

Avatar
Descartar
Autor

Where can I find this setting “Show Amount in Company Currency,”?

Mejor respuesta

Hello Mohamed,



To display order totals and line details in your company currency when dealing with foreign currency orders in Odoo Enterprise, you'll need to configure multi-currency settings properly.


Here's how you can achieve this:


  Enable Multi-Currency: Ensure that multi-currency is enabled in your Odoo settings. Go to Accounting -> Configuration -> Settings and check the 'Allow multi currencies' box.

  Set Company Currency: Verify that your company currency is correctly set in the company settings. Navigate to Settings -> Users & Companies -> Companies, then select your company and ensure the 'Currency' field is set to your desired base currency.

  Currency Rate Configuration: Odoo automatically converts foreign currency amounts to your company currency using the defined exchange rates. Make sure the exchange rates are up-to-date. You can manage these under Accounting -> Configuration -> Currencies.

  Reporting: When generating reports, Odoo will display amounts in the company currency by default. Ensure your reports are configured to show the company currency if needed.


For personalized assistance:
https://www.pragtech.co.in/contact-us-mql.html

Avatar
Descartar
Autor

I need to display it in the order form