From 39b9f72b465565fd992217d54900ec6449c07a78 Mon Sep 17 00:00:00 2001 From: Bastien PIERRE Date: Thu, 12 Oct 2023 14:40:23 +0200 Subject: [PATCH] [FIX] point_of_sale: Traceback when opening sale details report with studio Reproduction traceback: 1. Navigate to POS/Sessions 2. Open Studio 3. Navigate to Reports 4. Open Sale Details report After this commit, if the report is open without any session or config the currency used is the one from the company. closes odoo/odoo#139254 X-original-commit: 79be7208116f6c2749871c0af1d548da58b1b7fa Signed-off-by: Lucas Perais (lpe) --- addons/point_of_sale/models/report_sale_details.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/models/report_sale_details.py b/addons/point_of_sale/models/report_sale_details.py index 8b42f7dbe9b..cceefe214d3 100644 --- a/addons/point_of_sale/models/report_sale_details.py +++ b/addons/point_of_sale/models/report_sale_details.py @@ -62,7 +62,7 @@ class ReportSaleDetails(models.AbstractModel): 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): + if config_currencies and 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 @@ -92,7 +92,7 @@ class ReportSaleDetails(models.AbstractModel): payment_ids = self.env["pos.payment"].search([('pos_order_id', 'in', orders.ids)]).ids if payment_ids: self.env.cr.execute(""" - SELECT method.id as id, payment.session_id as session, COALESCE(method.name->>%s, method.name->>'en_US') as name, method.is_cash_count as cash, + SELECT method.id as id, payment.session_id as session, COALESCE(method.name->>%s, method.name->>'en_US') as name, method.is_cash_count as cash, sum(amount) total, method.journal_id journal_id FROM pos_payment AS payment, pos_payment_method AS method