From edb9914018cbf916a1f4d95b2b2ae58cb050eeff Mon Sep 17 00:00:00 2001 From: roen-odoo Date: Wed, 23 Aug 2023 15:09:01 +0200 Subject: [PATCH] [FIX] pos_daily_sales_reports: use pos config currency when possible Current behavior: The currency used to create the report is the one of the company. But if you use a different currency in the pos config, the report will still be in the company currency. To fix that we check if all report's config use the same currency and use it if it's the case we use the pos config currency. And if it's not possible we use the company currency. Steps to reproduce: - Create a second pos - Change the sale journal and the pricelist to use a different currency - Open a session and make a sale - Close the session - Generate the daily report for the second pos - The currency is the one of the company opw-3463280 closes odoo/odoo#133996 X-original-commit: 3af535d9008c4d839ede2b5117230fa4a19b538a Signed-off-by: Joseph Caburnay (jcb) Signed-off-by: Robin Engels (roen) --- addons/point_of_sale/models/report_sale_details.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/report_sale_details.py b/addons/point_of_sale/models/report_sale_details.py index daf5afe191c..a0e0cec063f 100644 --- a/addons/point_of_sale/models/report_sale_details.py +++ b/addons/point_of_sale/models/report_sale_details.py @@ -57,7 +57,15 @@ class ReportSaleDetails(models.AbstractModel): orders = self.env['pos.order'].search(domain) - user_currency = self.env.company.currency_id + if config_ids: + config_currencies = self.env['pos.config'].search([('id', 'in', config_ids)]).mapped('currency_id') + else: + config_currencies = self.env['pos.session'].search([('id', 'in', session_ids)]).mapped('config_id.currency_id') + # If all the pos.config have the same currency, we can use it, else we use the company currency + if all(i == config_currencies.ids[0] for i in config_currencies.ids): + user_currency = config_currencies[0] + else: + user_currency = self.env.company.currency_id total = 0.0 products_sold = {}