[FIX] point_of_sale: apply timezone on order list
Current behavior: When you open the order list, the orders are displayed in UTC. Steps to reproduce: - Be sure you are in a timezone different than UTC - Start a PoS restaurant session - Go on a table and make and order - Go on the order list - Go back on the table, then go back on the order list - The time showed for the order is not correct (it's in UTC) This bug was happening because `moment(order.validation_date)` consider that the date is already in the local timezone, so it doesn't apply the timezone offset. So we have to apply the offset manually before sending it to the frontend. opw-3002417 closes odoo/odoo#105417 X-original-commit: bd366a6d11fd8864b4c2fd2819463449d6da5278 Signed-off-by: Masereel Pierre <pim@odoo.com> Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
@@ -4,6 +4,8 @@ from itertools import groupby
|
||||
from re import search
|
||||
from functools import partial
|
||||
|
||||
import pytz
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
@@ -168,11 +170,12 @@ class PosOrder(models.Model):
|
||||
self._get_order_lines(table_orders)
|
||||
self._get_payment_lines(table_orders)
|
||||
|
||||
timezone = pytz.timezone(self._context.get('tz') or self.env.user.tz or 'UTC')
|
||||
for order in table_orders:
|
||||
order['pos_session_id'] = order['session_id'][0]
|
||||
order['uid'] = search(r"\d{5,}-\d{3,}-\d{4,}", order['pos_reference']).group(0)
|
||||
order['name'] = order['pos_reference']
|
||||
order['creation_date'] = order['create_date']
|
||||
order['creation_date'] = order['create_date'].astimezone(timezone)
|
||||
order['server_id'] = order['id']
|
||||
if order['fiscal_position_id']:
|
||||
order['fiscal_position_id'] = order['fiscal_position_id'][0]
|
||||
|
||||
Reference in New Issue
Block a user