[FIX] pos_coupon: warn user before deleting an active program in the order
It is possible that the user can mistakenly delete a reward line which completely deactivates the program in that order. We provide a warning message to the user to make sure of his intent. Part-of: odoo/odoo#77903
This commit is contained in:
committed by
Pierre Masereel
parent
21c1ed5b3a
commit
cfa93cabd1
@@ -16,6 +16,27 @@ odoo.define('pos_coupon.ProductScreen', function (require) {
|
||||
_onCouponScan(code) {
|
||||
this.currentOrder.activateCode(code.base_code);
|
||||
}
|
||||
async _updateSelectedOrderline(event) {
|
||||
const selectedLine = this.currentOrder.get_selected_orderline();
|
||||
if (selectedLine && selectedLine.is_program_reward && event.detail.key === 'Backspace') {
|
||||
const program = this.env.pos.coupon_programs_by_id[selectedLine.program_id]
|
||||
const { confirmed } = await this.showPopup('ConfirmPopup', {
|
||||
title: this.env._t('Deactivating program'),
|
||||
body: _.str.sprintf(
|
||||
this.env._t('Are you sure you want to deactivate %s in this order?'),
|
||||
program.name
|
||||
),
|
||||
cancelText: this.env._t('No'),
|
||||
confirmText: this.env._t('Yes'),
|
||||
});
|
||||
if (confirmed) {
|
||||
event.detail.buffer = null;
|
||||
} else {
|
||||
return; // do nothing on the line
|
||||
}
|
||||
}
|
||||
return super._updateSelectedOrderline(...arguments);
|
||||
}
|
||||
/**
|
||||
* 1/ Perform the usual set value operation (super._setValue) if the line being modified
|
||||
* is not a reward line or if it is a reward line, the `val` being set is '' or 'remove' only.
|
||||
|
||||
@@ -5,10 +5,12 @@ odoo.define('pos_coupon.tour.PosCouponTourMethods', function (require) {
|
||||
const { Do: ProductScreenDo } = require('point_of_sale.tour.ProductScreenTourMethods');
|
||||
const { Do: PaymentScreenDo } = require('point_of_sale.tour.PaymentScreenTourMethods');
|
||||
const { Do: ReceiptScreenDo } = require('point_of_sale.tour.ReceiptScreenTourMethods');
|
||||
const { Do: ChromeDo } = require('point_of_sale.tour.ChromeTourMethods');
|
||||
|
||||
const ProductScreen = { do: new ProductScreenDo() };
|
||||
const PaymentScreen = { do: new PaymentScreenDo() };
|
||||
const ReceiptScreen = { do: new ReceiptScreenDo() };
|
||||
const Chrome = { do: new ChromeDo() };
|
||||
|
||||
class Do {
|
||||
selectRewardLine(rewardName) {
|
||||
@@ -92,7 +94,11 @@ odoo.define('pos_coupon.tour.PosCouponTourMethods', function (require) {
|
||||
];
|
||||
}
|
||||
removeRewardLine(name) {
|
||||
return [...this.do.selectRewardLine(name), ...ProductScreen.do.pressNumpad('Backspace Backspace')];
|
||||
return [
|
||||
...this.do.selectRewardLine(name),
|
||||
...ProductScreen.do.pressNumpad('Backspace'),
|
||||
...Chrome.do.confirmPopup(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user