From 7db57de5d8da0fd61cf98bd184bfe00e4f070a3a Mon Sep 17 00:00:00 2001 From: Ivan Yelizariev Date: Fri, 20 May 2022 10:05:44 +0000 Subject: [PATCH] [FIX] pos_hr: update order's cashier on validation Module `pos_hr` allows to switch between cashiers (`hr.employee`) during the same POS session. The current cashier is printed on receipt and saved in backend. The story becomes more complicated if order is created by one cashier (e.g. Mitchel Admin), but validated by another (e.g. Mark Demo). In that case both receipt and backend must show the cashier who validated the order (i.e. Mark Demo). However, it wasn't the case before this patch: the receipt got Mark Demo as cashier and Mitchel Admin was saved in backend. Fix it by updating employee value on order validation. opw-2855234 closes odoo/odoo#92549 X-original-commit: b06c9793e13570bc84b1ddb52051e9fb039bc2c8 Signed-off-by: Trinh Jacky (trj) Signed-off-by: Ivan Elizaryev (iel) --- addons/pos_hr/__manifest__.py | 1 + addons/pos_hr/static/src/js/PaymentScreen.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 addons/pos_hr/static/src/js/PaymentScreen.js diff --git a/addons/pos_hr/__manifest__.py b/addons/pos_hr/__manifest__.py index 103180aefb9..804e049f4e1 100644 --- a/addons/pos_hr/__manifest__.py +++ b/addons/pos_hr/__manifest__.py @@ -29,6 +29,7 @@ The actual till still requires one user but an unlimited number of employees can 'pos_hr/static/src/js/HeaderLockButton.js', 'pos_hr/static/src/js/CashierName.js', 'pos_hr/static/src/js/LoginScreen.js', + 'pos_hr/static/src/js/PaymentScreen.js', ], 'web.assets_tests': [ 'pos_hr/static/tests/**/*', diff --git a/addons/pos_hr/static/src/js/PaymentScreen.js b/addons/pos_hr/static/src/js/PaymentScreen.js new file mode 100644 index 00000000000..98716a8eb8e --- /dev/null +++ b/addons/pos_hr/static/src/js/PaymentScreen.js @@ -0,0 +1,18 @@ +odoo.define('pos_hr.PaymentScreen', function (require) { + 'use strict'; + + const PaymentScreen = require('point_of_sale.PaymentScreen'); + const Registries = require('point_of_sale.Registries'); + + const PosHrPaymentScreen = (PaymentScreen_) => + class extends PaymentScreen_ { + async _finalizeValidation() { + this.currentOrder.employee = this.env.pos.get_cashier(); + await super._finalizeValidation(); + } + }; + + Registries.Component.extend(PaymentScreen, PosHrPaymentScreen); + + return PaymentScreen; +});