From f9fc43a1d0866c6d03f19d4e22cb03d514ae70a7 Mon Sep 17 00:00:00 2001 From: LorenzoC0 Date: Mon, 14 Oct 2024 15:13:30 +0200 Subject: [PATCH 1/5] [ADD] pos_full_refund: Added module to autocomplete full refunds on ticket screen. --- pos_full_refund/README.rst | 94 ++++ pos_full_refund/__manifest__.py | 19 + pos_full_refund/readme/CONTRIBUTORS.md | 4 + pos_full_refund/readme/DESCRIPTION.md | 1 + pos_full_refund/static/description/index.html | 437 ++++++++++++++++++ .../static/src/js/pos_full_refund.js | 19 + .../static/src/xml/pos_full_refund.xml | 21 + 7 files changed, 595 insertions(+) create mode 100644 pos_full_refund/README.rst create mode 100644 pos_full_refund/__manifest__.py create mode 100644 pos_full_refund/readme/CONTRIBUTORS.md create mode 100644 pos_full_refund/readme/DESCRIPTION.md create mode 100644 pos_full_refund/static/description/index.html create mode 100644 pos_full_refund/static/src/js/pos_full_refund.js create mode 100644 pos_full_refund/static/src/xml/pos_full_refund.xml diff --git a/pos_full_refund/README.rst b/pos_full_refund/README.rst new file mode 100644 index 0000000000..7e32c71168 --- /dev/null +++ b/pos_full_refund/README.rst @@ -0,0 +1,94 @@ +================ +Point of Sale - +================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:cc92aeed4d5986a6c3a0e7860d32d67c2aceec105975c3a9ffca2caab7ae128f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png + :target: https://odoo-community.org/page/development-status + :alt: Alpha +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github + :target: https://github.com/OCA/pos/tree/17.0/pos_full_refund + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_full_refund + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds a new button in the ticket screen to automatically add +the lines of the selected order and returns to the main screen. + +.. IMPORTANT:: + This is an alpha version, the data model and design can change at any time without warning. + Only for development or testing purpose, do not use in production. + `More details on development status `_ + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Innovyou + +Contributors +------------ + +- [Innovyou] (https://www.innovyou.it): + + - Lorenzo Carta + - Lorenzo Battistini + - Valerio Paretta + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-LorenzoC0| image:: https://github.com/LorenzoC0.png?size=40px + :target: https://github.com/LorenzoC0 + :alt: LorenzoC0 + +Current `maintainer `__: + +|maintainer-LorenzoC0| + +This module is part of the `OCA/pos `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_full_refund/__manifest__.py b/pos_full_refund/__manifest__.py new file mode 100644 index 0000000000..7d25d13d6c --- /dev/null +++ b/pos_full_refund/__manifest__.py @@ -0,0 +1,19 @@ +{ + "name": "Point of Sale - ", + "summary": "Short (1 phrase/line) summary of the module's purpose", + "author": "Innovyou, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/pos", + "development_status": "Alpha", + "category": "Point of sale", + "maintainers": ["LorenzoC0"], + "version": "17.0.1.0.0", + "license": "AGPL-3", + "installable": True, + "depends": ["point_of_sale"], + "assets": { + "point_of_sale._assets_pos": [ + "pos_full_refund/static/src/js/pos_full_refund.js", + "pos_full_refund/static/src/xml/pos_full_refund.xml", + ], + }, +} diff --git a/pos_full_refund/readme/CONTRIBUTORS.md b/pos_full_refund/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..85e9d7f0dd --- /dev/null +++ b/pos_full_refund/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- [Innovyou] (https://www.innovyou.it): + - Lorenzo Carta + - Lorenzo Battistini + - Valerio Paretta \ No newline at end of file diff --git a/pos_full_refund/readme/DESCRIPTION.md b/pos_full_refund/readme/DESCRIPTION.md new file mode 100644 index 0000000000..c2936156a7 --- /dev/null +++ b/pos_full_refund/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module adds a new button in the ticket screen to automatically add the lines of the selected order and returns to the main screen. \ No newline at end of file diff --git a/pos_full_refund/static/description/index.html b/pos_full_refund/static/description/index.html new file mode 100644 index 0000000000..5a233b6d9c --- /dev/null +++ b/pos_full_refund/static/description/index.html @@ -0,0 +1,437 @@ + + + + + +Point of Sale - + + + +
+

Point of Sale -

+ + +

Alpha License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

+

This module adds a new button in the ticket screen to automatically add +the lines of the selected order and returns to the main screen.

+
+

Important

+

This is an alpha version, the data model and design can change at any time without warning. +Only for development or testing purpose, do not use in production. +More details on development status

+
+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Innovyou
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

LorenzoC0

+

This module is part of the OCA/pos project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/pos_full_refund/static/src/js/pos_full_refund.js b/pos_full_refund/static/src/js/pos_full_refund.js new file mode 100644 index 0000000000..5de59c2fd4 --- /dev/null +++ b/pos_full_refund/static/src/js/pos_full_refund.js @@ -0,0 +1,19 @@ +/** @odoo-module **/ + +import {TicketScreen} from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; +import {_t} from "@web/core/l10n/translation"; +import {patch} from "@web/core/utils/patch"; + +patch(TicketScreen.prototype, { + onDoFullRefund() { + var selected_order = this.getSelectedOrder(); + for (const line of selected_order.orderlines) { + this.onClickOrderline(line); + for (const char of line.quantity.toString()) { + this._onUpdateSelectedOrderline({key: char, buffer: char}); + } + } + var pay_button = document.querySelector(".pay"); + pay_button.click(); + }, +}); diff --git a/pos_full_refund/static/src/xml/pos_full_refund.xml b/pos_full_refund/static/src/xml/pos_full_refund.xml new file mode 100644 index 0000000000..eba4ae8382 --- /dev/null +++ b/pos_full_refund/static/src/xml/pos_full_refund.xml @@ -0,0 +1,21 @@ + + + + + + + + + + From 7d1a12e451007f8c2b0c34194d4cebc8dbed4610 Mon Sep 17 00:00:00 2001 From: VPA Date: Tue, 12 Nov 2024 17:13:52 +0100 Subject: [PATCH 2/5] FIX corrected the refund process when pressed the Do full refund button if the quantity is lesser than 1 --- pos_full_refund/static/src/js/pos_full_refund.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pos_full_refund/static/src/js/pos_full_refund.js b/pos_full_refund/static/src/js/pos_full_refund.js index 5de59c2fd4..d0a773392f 100644 --- a/pos_full_refund/static/src/js/pos_full_refund.js +++ b/pos_full_refund/static/src/js/pos_full_refund.js @@ -8,12 +8,14 @@ patch(TicketScreen.prototype, { onDoFullRefund() { var selected_order = this.getSelectedOrder(); for (const line of selected_order.orderlines) { - this.onClickOrderline(line); - for (const char of line.quantity.toString()) { - this._onUpdateSelectedOrderline({key: char, buffer: char}); + const toRefundDetails = line + .getAllLinesInCombo() + .map((line) => this._getToRefundDetail(line)); + for (const toRefundDetail of toRefundDetails) { + toRefundDetail.qty = line.quantity; } } var pay_button = document.querySelector(".pay"); pay_button.click(); }, -}); +}); \ No newline at end of file From 9bd67c09f4d07e33b68c9e6bba80a02ed73cee11 Mon Sep 17 00:00:00 2001 From: eLBati Date: Mon, 7 Jul 2025 16:42:27 +0200 Subject: [PATCH 3/5] Porting pos_full_refund to v18 --- pos_full_refund/__manifest__.py | 6 +-- .../static/src/js/pos_full_refund.js | 49 ++++++++++++++----- 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/pos_full_refund/__manifest__.py b/pos_full_refund/__manifest__.py index 7d25d13d6c..3c6bad518e 100644 --- a/pos_full_refund/__manifest__.py +++ b/pos_full_refund/__manifest__.py @@ -1,12 +1,12 @@ { - "name": "Point of Sale - ", - "summary": "Short (1 phrase/line) summary of the module's purpose", + "name": "Point of Sale - Full Refund", + "summary": "Add button to easily perform full refunds in Point of Sale", "author": "Innovyou, Odoo Community Association (OCA)", "website": "https://github.com/OCA/pos", "development_status": "Alpha", "category": "Point of sale", "maintainers": ["LorenzoC0"], - "version": "17.0.1.0.0", + "version": "18.0.1.0.0", "license": "AGPL-3", "installable": True, "depends": ["point_of_sale"], diff --git a/pos_full_refund/static/src/js/pos_full_refund.js b/pos_full_refund/static/src/js/pos_full_refund.js index d0a773392f..f334dce7db 100644 --- a/pos_full_refund/static/src/js/pos_full_refund.js +++ b/pos_full_refund/static/src/js/pos_full_refund.js @@ -1,21 +1,46 @@ -/** @odoo-module **/ - import {TicketScreen} from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; import {_t} from "@web/core/l10n/translation"; import {patch} from "@web/core/utils/patch"; patch(TicketScreen.prototype, { onDoFullRefund() { - var selected_order = this.getSelectedOrder(); - for (const line of selected_order.orderlines) { - const toRefundDetails = line - .getAllLinesInCombo() - .map((line) => this._getToRefundDetail(line)); - for (const toRefundDetail of toRefundDetails) { - toRefundDetail.qty = line.quantity; + const order = this.getSelectedOrder(); + if (!order) { + return; + } + + // Initialize lineToRefund if it doesn't exist + if (!order.uiState.lineToRefund) { + order.uiState.lineToRefund = {}; + } + + // Set all orderlines to be fully refunded + for (const line of order.lines) { + const refundableQty = line.get_quantity() - line.refunded_qty; + if (refundableQty > 0) { + // Set the refund quantity in the UI state + order.uiState.lineToRefund[line.uuid] = { + qty: refundableQty, + line: line, + }; + + // Handle combo lines + if (line.combo_line_ids && line.combo_line_ids.length > 0) { + for (const comboLine of line.combo_line_ids) { + const comboRefundableQty = + comboLine.get_quantity() - comboLine.refunded_qty; + if (comboRefundableQty > 0) { + order.uiState.lineToRefund[comboLine.uuid] = { + qty: comboRefundableQty, + line: comboLine, + }; + } + } + } } } - var pay_button = document.querySelector(".pay"); - pay_button.click(); + + // Trigger the refund process + this.onDoRefund(); }, -}); \ No newline at end of file +}); From 4a67fd7ac50359ca1a64601575a45e46785381bf Mon Sep 17 00:00:00 2001 From: eLBati Date: Mon, 7 Jul 2025 16:43:00 +0200 Subject: [PATCH 4/5] [IMP] pos_full_refund: pre-commit auto fixes [IMP] pos_full_refund metadata [FIX] missing init [IMP] pos_full_refund with tests --- pos_full_refund/README.rst | 21 ++--- pos_full_refund/__init__.py | 0 pos_full_refund/__manifest__.py | 5 +- pos_full_refund/pyproject.toml | 3 + pos_full_refund/readme/DESCRIPTION.md | 2 +- pos_full_refund/static/description/index.html | 17 +++-- ...pos_full_refund.js => TicketScreen.esm.js} | 1 - .../tests/tours/PosFullRefund.tour.esm.js | 76 +++++++++++++++++++ pos_full_refund/tests/__init__.py | 1 + pos_full_refund/tests/test_pos_full_refund.py | 35 +++++++++ 10 files changed, 140 insertions(+), 21 deletions(-) create mode 100644 pos_full_refund/__init__.py create mode 100644 pos_full_refund/pyproject.toml rename pos_full_refund/static/src/js/{pos_full_refund.js => TicketScreen.esm.js} (97%) create mode 100644 pos_full_refund/static/tests/tours/PosFullRefund.tour.esm.js create mode 100644 pos_full_refund/tests/__init__.py create mode 100644 pos_full_refund/tests/test_pos_full_refund.py diff --git a/pos_full_refund/README.rst b/pos_full_refund/README.rst index 7e32c71168..efebf7cf1d 100644 --- a/pos_full_refund/README.rst +++ b/pos_full_refund/README.rst @@ -1,6 +1,6 @@ -================ -Point of Sale - -================ +=========================== +Point of Sale - Full Refund +=========================== .. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -17,19 +17,20 @@ Point of Sale - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github - :target: https://github.com/OCA/pos/tree/17.0/pos_full_refund + :target: https://github.com/OCA/pos/tree/18.0/pos_full_refund :alt: OCA/pos .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/pos-17-0/pos-17-0-pos_full_refund + :target: https://translation.odoo-community.org/projects/pos-18-0/pos-18-0-pos_full_refund :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=17.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=18.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| -This module adds a new button in the ticket screen to automatically add -the lines of the selected order and returns to the main screen. +This module adds a new button in the ticket screen of refund process to +automatically add every line of the selected order and returns to the +main screen. .. IMPORTANT:: This is an alpha version, the data model and design can change at any time without warning. @@ -47,7 +48,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -89,6 +90,6 @@ Current `maintainer `__: |maintainer-LorenzoC0| -This module is part of the `OCA/pos `_ project on GitHub. +This module is part of the `OCA/pos `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_full_refund/__init__.py b/pos_full_refund/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pos_full_refund/__manifest__.py b/pos_full_refund/__manifest__.py index 3c6bad518e..f7c7b54272 100644 --- a/pos_full_refund/__manifest__.py +++ b/pos_full_refund/__manifest__.py @@ -12,8 +12,11 @@ "depends": ["point_of_sale"], "assets": { "point_of_sale._assets_pos": [ - "pos_full_refund/static/src/js/pos_full_refund.js", + "pos_full_refund/static/src/js/TicketScreen.esm.js", "pos_full_refund/static/src/xml/pos_full_refund.xml", ], + "web.assets_tests": [ + "pos_full_refund/static/tests/tours/PosFullRefund.tour.esm.js", + ], }, } diff --git a/pos_full_refund/pyproject.toml b/pos_full_refund/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/pos_full_refund/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/pos_full_refund/readme/DESCRIPTION.md b/pos_full_refund/readme/DESCRIPTION.md index c2936156a7..57c9eae980 100644 --- a/pos_full_refund/readme/DESCRIPTION.md +++ b/pos_full_refund/readme/DESCRIPTION.md @@ -1 +1 @@ -This module adds a new button in the ticket screen to automatically add the lines of the selected order and returns to the main screen. \ No newline at end of file +This module adds a new button in the ticket screen of refund process to automatically add every line of the selected order and returns to the main screen. \ No newline at end of file diff --git a/pos_full_refund/static/description/index.html b/pos_full_refund/static/description/index.html index 5a233b6d9c..bd8a09e70e 100644 --- a/pos_full_refund/static/description/index.html +++ b/pos_full_refund/static/description/index.html @@ -3,7 +3,7 @@ -Point of Sale - +Point of Sale - Full Refund -
-

Point of Sale -

+
+

Point of Sale - Full Refund

-

Alpha License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

-

This module adds a new button in the ticket screen to automatically add -the lines of the selected order and returns to the main screen.

+

Alpha License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

+

This module adds a new button in the ticket screen of refund process to +automatically add every line of the selected order and returns to the +main screen.

Important

This is an alpha version, the data model and design can change at any time without warning. @@ -395,7 +396,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -428,7 +429,7 @@

Maintainers

promote its widespread use.

Current maintainer:

LorenzoC0

-

This module is part of the OCA/pos project on GitHub.

+

This module is part of the OCA/pos project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/pos_full_refund/static/src/js/pos_full_refund.js b/pos_full_refund/static/src/js/TicketScreen.esm.js similarity index 97% rename from pos_full_refund/static/src/js/pos_full_refund.js rename to pos_full_refund/static/src/js/TicketScreen.esm.js index f334dce7db..1234873a2d 100644 --- a/pos_full_refund/static/src/js/pos_full_refund.js +++ b/pos_full_refund/static/src/js/TicketScreen.esm.js @@ -1,5 +1,4 @@ import {TicketScreen} from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; -import {_t} from "@web/core/l10n/translation"; import {patch} from "@web/core/utils/patch"; patch(TicketScreen.prototype, { diff --git a/pos_full_refund/static/tests/tours/PosFullRefund.tour.esm.js b/pos_full_refund/static/tests/tours/PosFullRefund.tour.esm.js new file mode 100644 index 0000000000..f9a8db9f37 --- /dev/null +++ b/pos_full_refund/static/tests/tours/PosFullRefund.tour.esm.js @@ -0,0 +1,76 @@ +import * as ProductScreen from "@point_of_sale/../tests/tours/utils/product_screen_util"; +import * as PaymentScreen from "@point_of_sale/../tests/tours/utils/payment_screen_util"; +import * as ReceiptScreen from "@point_of_sale/../tests/tours/utils/receipt_screen_util"; +import * as TicketScreen from "@point_of_sale/../tests/tours/utils/ticket_screen_util"; +import * as Chrome from "@point_of_sale/../tests/tours/utils/chrome_util"; +import * as Dialog from "@point_of_sale/../tests/tours/utils/dialog_util"; +import * as Order from "@point_of_sale/../tests/tours/utils/generic_components/order_widget_util"; +import {registry} from "@web/core/registry"; + +registry.category("web_tour.tours").add("PosFullRefundTour", { + steps: () => + [ + // Start POS and open session + Chrome.startPoS(), + Dialog.confirm("Open Register"), + + // Create an order with multiple products + ProductScreen.addOrderline("Desk Pad", "2", "5"), + ProductScreen.addOrderline("Monitor Stand", "3", "4.5"), + ProductScreen.addOrderline("Letter Tray", "1", "5"), + + // Verify the order has multiple lines + Order.hasLine({productName: "Desk Pad", quantity: "2.00"}), + Order.hasLine({productName: "Monitor Stand", quantity: "3.00"}), + Order.hasLine({productName: "Letter Tray", quantity: "1.00"}), + + // Pay for the order + ProductScreen.clickPayButton(), + PaymentScreen.clickPaymentMethod("Bank"), + PaymentScreen.clickValidate(), + ReceiptScreen.isShown(), + ReceiptScreen.clickNextOrder(), + + // Go to refund mode + ...ProductScreen.clickRefund(), + + // Filter should be automatically 'Paid' + TicketScreen.filterIs("Paid"), + + // Select the order we just created + TicketScreen.selectOrder("-0001"), + + // Click the "Do Full Refund" button + { + trigger: "#set_full_refund_button", + run: "click", + }, + + // Verify we're back on product screen with refund order + { + ...ProductScreen.back(), + isActive: ["mobile"], + }, + ProductScreen.isShown(), + + // Verify all lines are in the refund order with negative quantities + Order.hasLine({ + productName: "Desk Pad", + quantity: "-2.00", + }), + Order.hasLine({ + productName: "Monitor Stand", + quantity: "-3.00", + }), + Order.hasLine({ + productName: "Letter Tray", + quantity: "-1.00", + }), + + // Complete the refund by paying + ProductScreen.clickPayButton(), + PaymentScreen.clickPaymentMethod("Bank"), + PaymentScreen.clickValidate(), + ReceiptScreen.isShown(), + ].flat(), +}); diff --git a/pos_full_refund/tests/__init__.py b/pos_full_refund/tests/__init__.py new file mode 100644 index 0000000000..0b3feafb34 --- /dev/null +++ b/pos_full_refund/tests/__init__.py @@ -0,0 +1 @@ +from . import test_pos_full_refund diff --git a/pos_full_refund/tests/test_pos_full_refund.py b/pos_full_refund/tests/test_pos_full_refund.py new file mode 100644 index 0000000000..57ae3dd66e --- /dev/null +++ b/pos_full_refund/tests/test_pos_full_refund.py @@ -0,0 +1,35 @@ +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.tests import tagged + +from odoo.addons.point_of_sale.tests.test_frontend import TestPointOfSaleHttpCommon + + +@tagged("post_install", "-at_install") +class TestPosFullRefund(TestPointOfSaleHttpCommon): + """Test the Full Refund functionality in POS. + + This test verifies that when a user clicks the "Do Full Refund" button + in the ticket screen, all lines from the selected order are automatically + added to a new refund order with their full quantities. + """ + + def test_pos_full_refund(self): + """Test that clicking 'Do Full Refund' creates a refund order with all lines.""" + # Open a POS session + self.main_pos_config.with_user(self.pos_user).open_ui() + + # Start the tour that will: + # 1. Create an order with multiple products + # (Desk Pad, Monitor Stand, Letter Tray) + # 2. Pay for the order + # 3. Open refund mode + # 4. Select the paid order + # 5. Click "Do Full Refund" button + # 6. Verify all lines are in the refund order with negative quantities + # 7. Complete the refund payment + self.start_tour( + "/pos/ui?config_id=%d" % self.main_pos_config.id, + "PosFullRefundTour", + login="pos_user", + ) From 3e62f772e009f54e62443f4620673f8c71f3c3d3 Mon Sep 17 00:00:00 2001 From: LorenzoC0 Date: Mon, 17 Nov 2025 18:22:55 +0100 Subject: [PATCH 5/5] [MIG] pos_full_refund: Migration to 16.0 --- pos_full_refund/README.rst | 10 +- pos_full_refund/__manifest__.py | 4 +- pos_full_refund/static/description/index.html | 6 +- .../static/src/js/TicketScreen.esm.js | 40 ++---- .../static/src/xml/pos_full_refund.xml | 9 +- .../tests/tours/PosFullRefund.tour.esm.js | 136 ++++++++---------- pos_full_refund/tests/test_pos_full_refund.py | 4 +- .../odoo/addons/pos_full_refund | 1 + setup/pos_full_refund/setup.py | 6 + 9 files changed, 98 insertions(+), 118 deletions(-) create mode 120000 setup/pos_full_refund/odoo/addons/pos_full_refund create mode 100644 setup/pos_full_refund/setup.py diff --git a/pos_full_refund/README.rst b/pos_full_refund/README.rst index efebf7cf1d..a7171e5ff0 100644 --- a/pos_full_refund/README.rst +++ b/pos_full_refund/README.rst @@ -17,13 +17,13 @@ Point of Sale - Full Refund :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github - :target: https://github.com/OCA/pos/tree/18.0/pos_full_refund + :target: https://github.com/OCA/pos/tree/16.0/pos_full_refund :alt: OCA/pos .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/pos-18-0/pos-18-0-pos_full_refund + :target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_full_refund :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=18.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/pos&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -48,7 +48,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -90,6 +90,6 @@ Current `maintainer `__: |maintainer-LorenzoC0| -This module is part of the `OCA/pos `_ project on GitHub. +This module is part of the `OCA/pos `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_full_refund/__manifest__.py b/pos_full_refund/__manifest__.py index f7c7b54272..95ee76678b 100644 --- a/pos_full_refund/__manifest__.py +++ b/pos_full_refund/__manifest__.py @@ -6,12 +6,12 @@ "development_status": "Alpha", "category": "Point of sale", "maintainers": ["LorenzoC0"], - "version": "18.0.1.0.0", + "version": "16.0.1.0.0", "license": "AGPL-3", "installable": True, "depends": ["point_of_sale"], "assets": { - "point_of_sale._assets_pos": [ + "point_of_sale.assets": [ "pos_full_refund/static/src/js/TicketScreen.esm.js", "pos_full_refund/static/src/xml/pos_full_refund.xml", ], diff --git a/pos_full_refund/static/description/index.html b/pos_full_refund/static/description/index.html index bd8a09e70e..4f974ba82a 100644 --- a/pos_full_refund/static/description/index.html +++ b/pos_full_refund/static/description/index.html @@ -369,7 +369,7 @@

Point of Sale - Full Refund

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:cc92aeed4d5986a6c3a0e7860d32d67c2aceec105975c3a9ffca2caab7ae128f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Alpha License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

+

Alpha License: AGPL-3 OCA/pos Translate me on Weblate Try me on Runboat

This module adds a new button in the ticket screen of refund process to automatically add every line of the selected order and returns to the main screen.

@@ -396,7 +396,7 @@

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -429,7 +429,7 @@

Maintainers

promote its widespread use.

Current maintainer:

LorenzoC0

-

This module is part of the OCA/pos project on GitHub.

+

This module is part of the OCA/pos project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/pos_full_refund/static/src/js/TicketScreen.esm.js b/pos_full_refund/static/src/js/TicketScreen.esm.js index 1234873a2d..1e89a9ba81 100644 --- a/pos_full_refund/static/src/js/TicketScreen.esm.js +++ b/pos_full_refund/static/src/js/TicketScreen.esm.js @@ -1,45 +1,27 @@ -import {TicketScreen} from "@point_of_sale/app/screens/ticket_screen/ticket_screen"; +/** @odoo-module **/ + +import TicketScreen from "point_of_sale.TicketScreen"; import {patch} from "@web/core/utils/patch"; -patch(TicketScreen.prototype, { +patch(TicketScreen.prototype, "pos_full_refund.TicketScreen", { onDoFullRefund() { - const order = this.getSelectedOrder(); + const order = this.getSelectedSyncedOrder(); if (!order) { return; } - // Initialize lineToRefund if it doesn't exist - if (!order.uiState.lineToRefund) { - order.uiState.lineToRefund = {}; - } - // Set all orderlines to be fully refunded - for (const line of order.lines) { + // In Odoo 16, we use env.pos.toRefundLines instead of order.uiState.lineToRefund + for (const line of order.get_orderlines()) { const refundableQty = line.get_quantity() - line.refunded_qty; if (refundableQty > 0) { - // Set the refund quantity in the UI state - order.uiState.lineToRefund[line.uuid] = { - qty: refundableQty, - line: line, - }; - - // Handle combo lines - if (line.combo_line_ids && line.combo_line_ids.length > 0) { - for (const comboLine of line.combo_line_ids) { - const comboRefundableQty = - comboLine.get_quantity() - comboLine.refunded_qty; - if (comboRefundableQty > 0) { - order.uiState.lineToRefund[comboLine.uuid] = { - qty: comboRefundableQty, - line: comboLine, - }; - } - } - } + // Get or create refund detail for this orderline + const toRefundDetail = this._getToRefundDetail(line); + toRefundDetail.qty = refundableQty; } } // Trigger the refund process - this.onDoRefund(); + this._onDoRefund(); }, }); diff --git a/pos_full_refund/static/src/xml/pos_full_refund.xml b/pos_full_refund/static/src/xml/pos_full_refund.xml index eba4ae8382..2a95f113ad 100644 --- a/pos_full_refund/static/src/xml/pos_full_refund.xml +++ b/pos_full_refund/static/src/xml/pos_full_refund.xml @@ -2,14 +2,19 @@ - +