File tree Expand file tree Collapse file tree 5 files changed +78
-0
lines changed
pos_payment_disable_multiselection Expand file tree Collapse file tree 5 files changed +78
-0
lines changed Original file line number Diff line number Diff line change 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 >`__
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ [build-system ]
2+ requires = [" whool" ]
3+ build-backend = " whool.buildapi"
Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments