[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) <jcb@odoo.com>
Signed-off-by: Robin Engels (roen) <roen@odoo.com>
This commit is contained in:
roen-odoo
2023-09-01 16:46:05 +00:00
parent b2b3613185
commit edb9914018
@@ -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 = {}