From 0602f5989ea0db3ae225a8d505e8d6cbf82c4875 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Fri, 8 May 2020 09:25:12 +0000 Subject: [PATCH] [FIX] point_of_sale: wrong date on session last closing date Before this commit, the last closing date of the POS didn't take into account the timezone. Now, the date take into account the timezone. opw-2231820 X-original-commit: 1b738ac4b8b52042976ad209a1968135c55a16dc --- addons/point_of_sale/models/pos_config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index bc23bb76163..3dca7adf993 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -3,6 +3,7 @@ from datetime import datetime from uuid import uuid4 +import pytz from odoo import api, fields, models, tools, _ from odoo.exceptions import ValidationError, UserError @@ -269,7 +270,8 @@ class PosConfig(models.Model): ['cash_register_balance_end_real', 'stop_at', 'cash_register_id'], order="stop_at desc", limit=1) if session: - pos_config.last_session_closing_date = session[0]['stop_at'].date() + timezone = pytz.timezone(self._context.get('tz') or self.env.user.tz or 'UTC') + pos_config.last_session_closing_date = session[0]['stop_at'].astimezone(timezone).date() if session[0]['cash_register_id']: pos_config.last_session_closing_cash = session[0]['cash_register_balance_end_real'] pos_config.last_session_closing_cashbox = self.env['account.bank.statement'].browse(session[0]['cash_register_id'][0]).cashbox_end_id