diff --git a/addons/point_of_sale/static/src/js/Chrome.js b/addons/point_of_sale/static/src/js/Chrome.js
index 008ebe38ba3..6512b3abd00 100644
--- a/addons/point_of_sale/static/src/js/Chrome.js
+++ b/addons/point_of_sale/static/src/js/Chrome.js
@@ -245,7 +245,7 @@ odoo.define('point_of_sale.Chrome', function(require) {
openCashControl() {
if (this.shouldShowCashControl()) {
- this.showPopup('CashOpeningPopup', { cancelKey: false });
+ this.showPopup('CashOpeningPopup');
}
}
diff --git a/addons/point_of_sale/static/src/js/Popups/CashOpeningPopup.js b/addons/point_of_sale/static/src/js/Popups/CashOpeningPopup.js
index de6fb069a16..a42e56b2f69 100644
--- a/addons/point_of_sale/static/src/js/Popups/CashOpeningPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/CashOpeningPopup.js
@@ -16,6 +16,17 @@ odoo.define('point_of_sale.CashOpeningPopup', function(require) {
displayMoneyDetailsPopup: false,
});
}
+ //@override
+ async confirm() {
+ this.env.pos.bank_statement.balance_start = this.state.openingCash;
+ this.env.pos.pos_session.state = 'opened';
+ this.rpc({
+ model: 'pos.session',
+ method: 'set_cashbox_pos',
+ args: [this.env.pos.pos_session.id, this.state.openingCash, this.state.notes],
+ });
+ super.confirm();
+ }
openDetailsPopup() {
this.state.openingCash = 0;
this.state.notes = "";
@@ -24,16 +35,6 @@ odoo.define('point_of_sale.CashOpeningPopup', function(require) {
closeDetailsPopup() {
this.state.displayMoneyDetailsPopup = false;
}
- startSession() {
- this.env.pos.bank_statement.balance_start = this.state.openingCash;
- this.env.pos.pos_session.state = 'opened';
- this.rpc({
- model: 'pos.session',
- method: 'set_cashbox_pos',
- args: [this.env.pos.pos_session.id, this.state.openingCash, this.state.notes],
- });
- this.cancel(); // close popup
- }
updateCashOpening({ total, moneyDetailsNotes }) {
this.state.openingCash = total;
if (moneyDetailsNotes) {
@@ -49,6 +50,7 @@ odoo.define('point_of_sale.CashOpeningPopup', function(require) {
}
CashOpeningPopup.template = 'CashOpeningPopup';
+ CashOpeningPopup.defaultProps = { cancelKey: false };
Registries.Component.add(CashOpeningPopup);
return CashOpeningPopup;
diff --git a/addons/point_of_sale/static/src/js/Popups/ClosePosPopup.js b/addons/point_of_sale/static/src/js/Popups/ClosePosPopup.js
index f7617372029..63419c95f0a 100644
--- a/addons/point_of_sale/static/src/js/Popups/ClosePosPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/ClosePosPopup.js
@@ -53,7 +53,7 @@ odoo.define('point_of_sale.ClosePosPopup', function(require) {
}
Object.assign(this.state, state);
} catch (error) {
- this.cancel();
+ super.cancel();
if (identifyError(error) instanceof ConnectionLostError) {
this.showPopup('ErrorPopup', {
title: this.env._t('Network Error'),
@@ -64,6 +64,36 @@ odoo.define('point_of_sale.ClosePosPopup', function(require) {
}
}
}
+ //@override
+ async confirm() {
+ if (!this.cashControl || !this.hasDifference()) {
+ this.closeSession();
+ } else if (this.hasUserAuthority()) {
+ const { confirmed } = await this.showPopup('ConfirmPopup', {
+ title: this.env._t('Payments Difference'),
+ body: this.env._t('Do you want to accept payments difference and post a profit/loss journal entry?'),
+ });
+ if (confirmed) {
+ this.closeSession();
+ }
+ } else {
+ await this.showPopup('ConfirmPopup', {
+ title: this.env._t('Payments Difference'),
+ body: _.str.sprintf(
+ this.env._t('The maximum difference allowed is %s.\n\
+ Please contact your manager to accept the closing difference.'),
+ this.env.pos.format_currency(this.amountAuthorizedDiff)
+ ),
+ confirmText: this.env._t('OK'),
+ })
+ }
+ }
+ //@override
+ async cancel() {
+ if (this.canCancel()) {
+ super.cancel();
+ }
+ }
openDetailsPopup() {
this.state.payments[this.defaultCashDetails.id].counted = 0;
this.state.payments[this.defaultCashDetails.id].difference = -this.defaultCashDetails.amount;
@@ -110,37 +140,9 @@ odoo.define('point_of_sale.ClosePosPopup', function(require) {
const absDifferences = Object.entries(this.state.payments).map(pm => Math.abs(pm[1].difference));
return this.isManager || this.amountAuthorizedDiff == null || Math.max(...absDifferences) <= this.amountAuthorizedDiff;
}
- async onCloseSession() {
- if (!this.cashControl || !this.hasDifference()) {
- this.closeSession();
- } else if (this.hasUserAuthority()) {
- const { confirmed } = await this.showPopup('ConfirmPopup', {
- title: this.env._t('Payments Difference'),
- body: this.env._t('Do you want to accept payments difference and post a profit/loss journal entry?'),
- });
- if (confirmed) {
- this.closeSession();
- }
- } else {
- await this.showPopup('ConfirmPopup', {
- title: this.env._t('Payments Difference'),
- body: _.str.sprintf(
- this.env._t('The maximum difference allowed is %s.\n\
- Please contact your manager to accept the closing difference.'),
- this.env.pos.format_currency(this.amountAuthorizedDiff)
- ),
- confirmText: this.env._t('OK'),
- })
- }
- }
canCancel() {
return true;
}
- cancelPopup() {
- if (this.canCancel()) {
- this.cancel();
- }
- }
closePos() {
this.trigger('close-pos');
}
diff --git a/addons/point_of_sale/static/src/js/Popups/ControlButtonPopup.js b/addons/point_of_sale/static/src/js/Popups/ControlButtonPopup.js
index 2da01ee821e..924accf4b7f 100644
--- a/addons/point_of_sale/static/src/js/Popups/ControlButtonPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/ControlButtonPopup.js
@@ -18,7 +18,8 @@ odoo.define('point_of_sale.ControlButtonPopup', function(require) {
ControlButtonPopup.template = 'ControlButtonPopup';
ControlButtonPopup.defaultProps = {
cancelText: _lt('Back'),
- controlButtons: []
+ controlButtons: [],
+ confirmKey: false,
};
Registries.Component.add(ControlButtonPopup);
diff --git a/addons/point_of_sale/static/src/js/Popups/ErrorPopup.js b/addons/point_of_sale/static/src/js/Popups/ErrorPopup.js
index 3d2bfc0f311..8300b6a5749 100644
--- a/addons/point_of_sale/static/src/js/Popups/ErrorPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/ErrorPopup.js
@@ -18,9 +18,9 @@ odoo.define('point_of_sale.ErrorPopup', function(require) {
ErrorPopup.template = 'ErrorPopup';
ErrorPopup.defaultProps = {
confirmText: _lt('Ok'),
- cancelText: _lt('Cancel'),
title: _lt('Error'),
body: '',
+ cancelKey: false,
};
Registries.Component.add(ErrorPopup);
diff --git a/addons/point_of_sale/static/src/js/Popups/ErrorTracebackPopup.js b/addons/point_of_sale/static/src/js/Popups/ErrorTracebackPopup.js
index b9ca658e855..c8990ad5578 100644
--- a/addons/point_of_sale/static/src/js/Popups/ErrorTracebackPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/ErrorTracebackPopup.js
@@ -32,6 +32,7 @@ odoo.define('point_of_sale.ErrorTracebackPopup', function(require) {
ErrorTracebackPopup.defaultProps = {
confirmText: _lt('Ok'),
cancelText: _lt('Cancel'),
+ confirmKey: false,
title: _lt('Error with Traceback'),
body: '',
exitButtonIsShown: false,
diff --git a/addons/point_of_sale/static/src/js/Popups/OrderImportPopup.js b/addons/point_of_sale/static/src/js/Popups/OrderImportPopup.js
index 8395bf28c81..951957819a5 100644
--- a/addons/point_of_sale/static/src/js/Popups/OrderImportPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/OrderImportPopup.js
@@ -18,7 +18,7 @@ odoo.define('point_of_sale.OrderImportPopup', function(require) {
OrderImportPopup.template = 'OrderImportPopup';
OrderImportPopup.defaultProps = {
confirmText: _lt('Ok'),
- cancelText: _lt('Cancel'),
+ cancelKey: false,
body: '',
};
diff --git a/addons/point_of_sale/static/src/js/Popups/ProductInfoPopup.js b/addons/point_of_sale/static/src/js/Popups/ProductInfoPopup.js
index a066cc7db11..ceaadff49b3 100644
--- a/addons/point_of_sale/static/src/js/Popups/ProductInfoPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/ProductInfoPopup.js
@@ -71,5 +71,6 @@ odoo.define('point_of_sale.ProductInfoPopup', function(require) {
}
ProductInfoPopup.template = 'ProductInfoPopup';
+ ProductInfoPopup.defaultProps= { confirmKey: false };
Registries.Component.add(ProductInfoPopup);
});
diff --git a/addons/point_of_sale/static/src/js/Popups/SelectionPopup.js b/addons/point_of_sale/static/src/js/Popups/SelectionPopup.js
index 944fb7c11fa..c74e0fc9c90 100644
--- a/addons/point_of_sale/static/src/js/Popups/SelectionPopup.js
+++ b/addons/point_of_sale/static/src/js/Popups/SelectionPopup.js
@@ -46,11 +46,11 @@ odoo.define('point_of_sale.SelectionPopup', function (require) {
}
SelectionPopup.template = 'SelectionPopup';
SelectionPopup.defaultProps = {
- confirmText: _lt('Confirm'),
cancelText: _lt('Cancel'),
title: _lt('Select'),
body: '',
list: [],
+ confirmKey: false,
};
Registries.Component.add(SelectionPopup);
diff --git a/addons/point_of_sale/static/src/xml/Popups/CashOpeningPopup.xml b/addons/point_of_sale/static/src/xml/Popups/CashOpeningPopup.xml
index 98a6d5f7705..5003319956b 100644
--- a/addons/point_of_sale/static/src/xml/Popups/CashOpeningPopup.xml
+++ b/addons/point_of_sale/static/src/xml/Popups/CashOpeningPopup.xml
@@ -18,7 +18,7 @@