[FIX] pos_restaurant: Timezone inconsistency in draft orders
Right now when you create an order (order A) in a POS with tables the `date_order` is being set correctly (in UTC, so is shown in the back-end with the user's timezone), but after you return to the Floor Screen or go to another order (order B) and then go back to the order A and you add another product and the order is saved (not paid) when you check that order in the back-end now the `date_order` it says another value not the one of the user's. This is happening because when the JS received the back-end information to open the order for the second time the date come in the User's timezone and the server's timezone, and that info was saved but taking it like UTC. Now instead of storing inconsistent information in the DB (server side), we are going to modify the information that is shown in the POS (client side), so that both sides show the same date. This will only apply in the POS where tables are being used since the orders are only synchronized (back-end) when the option `is_table_management` is set in the POS (`pos.config`). closes odoo/odoo#110832 X-original-commit: 168d0e12120ced7b1093d39b10cd79c85c56aad0 Signed-off-by: Trinh Jacky (trj) <trj@odoo.com>
This commit is contained in:
committed by
Jacky (trj)
parent
64210e5870
commit
27fed3392b
@@ -178,12 +178,11 @@ 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'].astimezone(timezone)
|
||||
order['creation_date'] = order['create_date']
|
||||
order['server_id'] = order['id']
|
||||
if order['fiscal_position_id']:
|
||||
order['fiscal_position_id'] = order['fiscal_position_id'][0]
|
||||
|
||||
@@ -369,6 +369,7 @@ patch(Order.prototype, "pos_restaurant.Order", {
|
||||
if (this.pos.config.module_pos_restaurant) {
|
||||
if (this.pos.config.iface_floorplan) {
|
||||
this.tableId = json.table_id;
|
||||
this.validation_date = moment.utc(json.creation_date).local().toDate();
|
||||
}
|
||||
this.customerCount = json.customer_count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user