Skip to content

Commit 0159b3c

Browse files
committed
[MIG] pos_payment_disable_multiselection: Migration to 17.0
1 parent b1ed758 commit 0159b3c

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
================================================================
2+
Disabling multiple selection for the same Payment Method in POS
3+
================================================================
4+
5+
* Prevents adding the same payment method multiple times in the POS Payment Screen
6+
7+
* Automatically focuses the existing payment line if the user clicks the same payment method again
8+
9+
* Cleans up the duplicated payment lines if they exist (e.g. when navigating back to cart and forth)
10+
11+
* Improves UX by ensuring only one line per payment method is shown
12+
13+
Usage
14+
-----
15+
16+
* Open Main menu → Point of Sale → Start a session
17+
18+
* Add products to cart and go to the Payment screen
19+
20+
* Click the same payment method multiple times
21+
22+
* RESULT: only one payment line is present for the selected method
23+
24+
* If a payment method is already selected, clicking it again will simply focus the existing line
25+
26+
Credits
27+
=======
28+
29+
Contributors
30+
------------
31+
32+
* `Almas Kopeyev <https://github.com/kopeyev>`__
33+
34+
Maintainers
35+
-----------
36+
37+
* `IT-Projects LLC <https://it-projects.info>`__

pos_payment_disable_multiselection/__init__.py

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "POS: disable multiple select for payment method",
3+
"summary": "Prevent selecting the same payment method multiple times in POS",
4+
"author": "Almas Kopeyev, IT-Projects LLC",
5+
"version": "17.0.1.0.0",
6+
"website": "https://github.com/it-projects-llc/pos-addons",
7+
"depends": ["point_of_sale"],
8+
"data": [],
9+
"assets": {
10+
"point_of_sale._assets_pos": [
11+
"pos_payment_disable_multiselection/static/src/js/PaymentScreen.js",
12+
],
13+
},
14+
"license": "LGPL-3",
15+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/** @odoo-module **/
2+
3+
import {PaymentScreen} from "@point_of_sale/app/screens/payment_screen/payment_screen";
4+
import {patch} from "@web/core/utils/patch";
5+
6+
patch(PaymentScreen.prototype, {
7+
addNewPaymentLine(paymentMethod) {
8+
const matchingLines = this.currentOrder
9+
.get_paymentlines()
10+
.filter((line) => line.payment_method.id === paymentMethod.id);
11+
12+
if (matchingLines.length > 0) {
13+
// Delete all duplicate payment lines except the first
14+
for (let i = 1; i < matchingLines.length; i++) {
15+
this.deletePaymentLine(matchingLines[i].cid);
16+
}
17+
// Select the first line
18+
this.selectPaymentLine(matchingLines[0].cid);
19+
return true;
20+
}
21+
return super.addNewPaymentLine(paymentMethod);
22+
},
23+
});

0 commit comments

Comments
 (0)