[FIX] pos_self_order: some bugs fixes

- Corrected incorrect use of access_token in an order.
- Correction of order change calculation in self_order.

closes odoo/odoo#125941

Signed-off-by: Robin Heinz (rhe) <rhe@odoo.com>
This commit is contained in:
David Monnom (moda)
2023-07-13 19:28:01 +02:00
parent 0a6cac7002
commit b0668f106e
4 changed files with 21 additions and 3 deletions
+7 -1
View File
@@ -36,7 +36,7 @@ class PosQRMenuController(http.Controller):
pos_config_sudo = False
pos_config_access_token = False
if config_id and config_id.isnumeric():
if config_id and config_id.isnumeric() and access_token:
pos_config_sudo = request.env["pos.config"].sudo().search([
("id", "=", config_id),
('access_token', '=', access_token)], limit=1)
@@ -46,9 +46,15 @@ class PosQRMenuController(http.Controller):
pos_config_access_token = pos_config_sudo.access_token
table_sudo = get_table_sudo(identifier=table_identifier)
table_infos = table_sudo._get_self_order_data() if table_sudo else False
elif config_id and config_id.isnumeric():
pos_config_sudo = request.env["pos.config"].sudo().search([
("id", "=", config_id), ("self_order_view_mode", "=", True)], limit=1)
else:
pos_config_sudo = get_any_pos_config_sudo()
if not pos_config_sudo:
raise werkzeug.exceptions.NotFound()
return request.render(
'pos_self_order.index',
{
@@ -30,4 +30,14 @@ export class Line extends Reactive {
this.price_subtotal = line.price_subtotal || 0;
this.selected_attributes = line.selected_attributes || [];
}
isChange(lastChange) {
for (const key in lastChange) {
if (JSON.stringify(lastChange[key]) !== JSON.stringify(this[key])) {
return true;
}
}
return false;
}
}
@@ -60,6 +60,8 @@ export class Order extends Reactive {
this.lastChangesSent = this.lines.reduce((acc, line) => {
acc[line.uuid] = {
qty: line.qty,
selected_attributes: line.selected_attributes,
customer_note: line.customer_note,
};
return acc;
}, {});
@@ -73,7 +75,7 @@ export class Order extends Reactive {
return true;
}
return lastSend.qty !== line.qty;
return lastSend.qty !== line.qty || line.isChange(lastSend);
});
}
}
@@ -11,7 +11,7 @@
</div>
</main>
<div class="d-flex flex-column align-items-center w-100 p-3 bg-white shadow-lg">
<button t-on-click="processOrder" t-attf-class="o_self_order_main_button btn btn-primary w-100 px-2 py-3 mt-2 rounded">
<button t-on-click="processOrder" t-attf-class="{{ !orderToPay and !order.isChange() ? 'disabled' : '' }} o_self_order_main_button btn btn-primary w-100 px-2 py-3 mt-2 rounded">
<span t-if="orderToPay">Pay</span>
<span t-else="">Order</span>
<t t-if="!selfOrder.priceLoading">