[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
This commit is contained in:
Jorge Pinna Puissant
2020-05-11 09:32:36 +00:00
parent 01c64f3907
commit 0602f5989e
+3 -1
View File
@@ -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