From c5f9c5e9314559100ee61b879fc4eb3d971c81c8 Mon Sep 17 00:00:00 2001 From: RisvanaCybro Date: Fri, 3 May 2024 23:46:11 +0530 Subject: [PATCH] May 03: [FIX] Bug Fixed 'product_profit_report' --- product_profit_report/doc/RELEASE_NOTES.md | 5 +++++ .../report/product_profit_report.py | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/product_profit_report/doc/RELEASE_NOTES.md b/product_profit_report/doc/RELEASE_NOTES.md index 4f31cc329..8d98a5e98 100644 --- a/product_profit_report/doc/RELEASE_NOTES.md +++ b/product_profit_report/doc/RELEASE_NOTES.md @@ -4,3 +4,8 @@ #### Version 16.0.1.0.0 ##### ADD - Initial commit for Product Profit Report + +#### 03.05.2024 +#### Version 16.0.1.0.0 +##### Bug Fix +- Bug fix- Multi Currency diff --git a/product_profit_report/report/product_profit_report.py b/product_profit_report/report/product_profit_report.py index a150a21a5..6fb981c48 100644 --- a/product_profit_report/report/product_profit_report.py +++ b/product_profit_report/report/product_profit_report.py @@ -20,7 +20,7 @@ # ################################################################################ import datetime -from odoo import api, models, _ +from odoo import api, fields, models, _ from odoo.exceptions import ValidationError @@ -53,6 +53,16 @@ class ProductProfitReport(models.AbstractModel): dic_name = str(order.product_id.id) quantity = order.quantity price = quantity * (order.price_unit - order.discount) + if order.currency_id != order.company_currency_id: + currency_rate = self.env[ + 'res.currency']._get_conversion_rate( + from_currency=order.currency_id, + to_currency=order.company_currency_id, + company=order.company_id, + date=order.move_id.invoice_date or order.move_id.date or fields.Date.context_today( + order)) + price = order.company_currency_id.round( + price * currency_rate) expense = order.product_id.get_history_price( order.company_id.id, date=order.move_id.invoice_date) * quantity